You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by vl...@apache.org on 2014/12/13 12:24:16 UTC

[1/2] incubator-calcite git commit: Fix javadoc errors for java8

Repository: incubator-calcite
Updated Branches:
  refs/heads/master 501040719 -> b7427ed74


Fix javadoc errors for java8

fixes #30


Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/7eb1bfdb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/7eb1bfdb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/7eb1bfdb

Branch: refs/heads/master
Commit: 7eb1bfdb06a568ae537bbd1b63c0fb4c0e759a9c
Parents: 5010407
Author: Vladimir Sitnikov <si...@gmail.com>
Authored: Sat Dec 13 14:04:46 2014 +0300
Committer: Vladimir Sitnikov <si...@gmail.com>
Committed: Sat Dec 13 14:04:46 2014 +0300

----------------------------------------------------------------------
 .../adapter/enumerable/AggAddContext.java       |  2 +
 .../calcite/adapter/enumerable/AggContext.java  |  4 ++
 .../adapter/enumerable/AggImplementor.java      | 21 +++++----
 .../adapter/enumerable/CallImplementor.java     |  9 +++-
 .../enumerable/EnumerableInterpreter.java       |  9 +++-
 .../adapter/enumerable/EnumerableRel.java       |  1 +
 .../adapter/enumerable/JavaRelImplementor.java  |  8 +++-
 .../org/apache/calcite/plan/RelOptNode.java     | 11 +++++
 .../org/apache/calcite/plan/RelOptRule.java     | 47 +++++++++++++++++---
 .../java/org/apache/calcite/plan/RelTrait.java  |  3 ++
 .../org/apache/calcite/rel/AbstractRelNode.java |  3 ++
 .../java/org/apache/calcite/rel/RelNode.java    | 46 +++++++++++++++++--
 .../calcite/rel/convert/ConverterRule.java      |  3 ++
 .../org/apache/calcite/rel/core/Aggregate.java  | 36 ++++++++++++++-
 .../java/org/apache/calcite/rel/core/Calc.java  | 25 ++++++++++-
 .../org/apache/calcite/rel/core/Correlate.java  | 40 ++++++++++-------
 .../java/org/apache/calcite/rel/core/Join.java  |  7 ++-
 .../org/apache/calcite/rel/core/Project.java    | 24 +++++++++-
 .../java/org/apache/calcite/rel/core/SetOp.java |  2 +
 .../calcite/rel/type/RelDataTypeFactory.java    |  2 +
 .../java/org/apache/calcite/schema/Schema.java  | 16 ++++++-
 .../apache/calcite/schema/SchemaFactory.java    |  1 +
 .../calcite/schema/impl/AbstractSchema.java     | 12 +++--
 23 files changed, 284 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/adapter/enumerable/AggAddContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/AggAddContext.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/AggAddContext.java
index a66e2d7..9f8f595 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/AggAddContext.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/AggAddContext.java
@@ -50,6 +50,8 @@ public interface AggAddContext extends AggResultContext {
    * Returns a
    * {@link org.apache.calcite.adapter.enumerable.RexToLixTranslator}
    * suitable to transform the arguments.
+   *
+   * @return {@link RexToLixTranslator} suitable to transform the arguments
    */
   RexToLixTranslator rowTranslator();
 }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/adapter/enumerable/AggContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/AggContext.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/AggContext.java
index a72471a..542e3a2 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/AggContext.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/AggContext.java
@@ -55,12 +55,16 @@ public interface AggContext {
    * {@link org.apache.calcite.rel.type.RelDataType}.
    * This can be helpful to test
    * {@link org.apache.calcite.rel.type.RelDataType#isNullable()}.
+   *
+   * @return Parameter types of the aggregate
    */
   List<? extends RelDataType> parameterRelTypes();
 
   /**
    * Returns the parameter types of the aggregate as
    * {@link java.lang.reflect.Type}.
+   *
+   * @return Parameter types of the aggregate
    */
   List<? extends Type> parameterTypes();
 }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/adapter/enumerable/AggImplementor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/AggImplementor.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/AggImplementor.java
index 6f70828..ed99ac5 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/AggImplementor.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/AggImplementor.java
@@ -39,8 +39,8 @@ public interface AggImplementor {
    * {@link java.lang.StringBuilder}.
    * Calcite calls this method before all other {@code implement*} methods.
    *
-   * @param info aggregate context
-   * @return types of the intermediate variables used by the aggregate
+   * @param info Aggregate context
+   * @return Types of the intermediate variables used by the aggregate
    *   implementation
    */
   List<Type> getStateType(AggContext info);
@@ -52,8 +52,9 @@ public interface AggImplementor {
    * For instance, to zero the count use the following code:
    * {@code reset.currentBlock().add(Expressions.statement(
    * Expressions.assign(reset.accumulator().get(0), Expressions.constant(0)));}
-   * @param info aggregate context
-   * @param reset reset context
+   *
+   * @param info Aggregate context
+   * @param reset Reset context
    */
   void implementReset(AggContext info, AggResetContext reset);
 
@@ -61,8 +62,9 @@ public interface AggImplementor {
    * Updates intermediate values to account for the newly added value.
    * {@link AggResetContext#accumulator()} should be used to reference
    * the state variables.
-   * @param info aggregate context
-   * @param add add context
+   *
+   * @param info Aggregate context
+   * @param add Add context
    */
   void implementAdd(AggContext info, AggAddContext add);
 
@@ -72,8 +74,11 @@ public interface AggImplementor {
    * calcite might reuse the state when calculating sliding aggregates.
    * {@link AggResetContext#accumulator()} should be used to reference
    * the state variables.
-   * @param info aggregate context
-   * @param result result context
+   *
+   * @param info Aggregate context
+   * @param result Result context
+   * @return Expression that is a result of calculating final value of
+   *   the aggregate being implemented
    */
   Expression implementResult(AggContext info, AggResultContext result);
 }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/adapter/enumerable/CallImplementor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/CallImplementor.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/CallImplementor.java
index 8f8ea68..a258082 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/CallImplementor.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/CallImplementor.java
@@ -27,7 +27,14 @@ import org.apache.calcite.rex.RexCall;
  * @see org.apache.calcite.adapter.enumerable.RexImpTable
  */
 public interface CallImplementor {
-  /** Implements a call. */
+  /**
+   * Implements a call.
+   *
+   * @param translator Translator for the call
+   * @param call Call that should be implemented
+   * @param nullAs The desired mode of {@code null} translation
+   * @return Translated call
+   */
   Expression implement(
       RexToLixTranslator translator,
       RexCall call,

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpreter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpreter.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpreter.java
index 64b0c6f..988464e 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpreter.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpreter.java
@@ -42,7 +42,14 @@ public class EnumerableInterpreter extends SingleRel
     implements EnumerableRel {
   private final double factor;
 
-  /** Creates an EnumerableInterpreterRel. */
+  /**
+   * Creates an EnumerableInterpreter.
+   *
+   * @param cluster Cluster
+   * @param traitSet Traits
+   * @param input Input relation
+   * @param factor Cost multiply factor
+   */
   public EnumerableInterpreter(RelOptCluster cluster,
       RelTraitSet traitSet, RelNode input, double factor) {
     super(cluster, traitSet, input);

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRel.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRel.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRel.java
index 8c74f73..247e4f7 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRel.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRel.java
@@ -66,6 +66,7 @@ public interface EnumerableRel
    *
    * @param implementor Implementor
    * @param pref Preferred representation for rows in result expression
+   * @return Plan for this expression according to a calling convention
    */
   Result implement(EnumerableRelImplementor implementor, Prefer pref);
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/adapter/enumerable/JavaRelImplementor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/JavaRelImplementor.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/JavaRelImplementor.java
index cd0c3f5..c4209a3 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/JavaRelImplementor.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/JavaRelImplementor.java
@@ -43,8 +43,12 @@ public abstract class JavaRelImplementor implements RelImplementor {
     return (JavaTypeFactory) rexBuilder.getTypeFactory();
   }
 
-  /** Returns the expression with which to access the
-   * {@link org.apache.calcite.DataContext}. */
+  /**
+   * Returns the expression used to access
+   * {@link org.apache.calcite.DataContext}.
+   *
+   * @return expression used to access {@link org.apache.calcite.DataContext}.
+   */
   public ParameterExpression getRootExpression() {
     return DataContext.ROOT;
   }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/plan/RelOptNode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptNode.java b/core/src/main/java/org/apache/calcite/plan/RelOptNode.java
index 4117dd3..85da2bc 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptNode.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptNode.java
@@ -44,6 +44,8 @@ public interface RelOptNode {
    *
    * <p>If you want a descriptive string which contains the identity, call
    * {@link Object#toString()}, which always returns "rel#{id}:{digest}".
+   *
+   * @return Digest of this {@code RelNode}
    */
   String getDigest();
 
@@ -67,9 +69,18 @@ public interface RelOptNode {
    * Returns a string which describes the relational expression and, unlike
    * {@link #getDigest()}, also includes the identity. Typically returns
    * "rel#{id}:{digest}".
+   *
+   * @return String which describes the relational expression and, unlike
+   *   {@link #getDigest()}, also includes the identity
    */
   String getDescription();
 
+  /**
+   * Returns an array of this relational expression's inputs. If there are no
+   * inputs, returns an empty list, not {@code null}.
+   *
+   * @return Array of this relational expression's inputs
+   */
   List<? extends RelOptNode> getInputs();
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/plan/RelOptRule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptRule.java b/core/src/main/java/org/apache/calcite/plan/RelOptRule.java
index 788b88d..058736d 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptRule.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptRule.java
@@ -96,7 +96,10 @@ public abstract class RelOptRule {
    * children.
    *
    * @param clazz Class of relational expression to match (must not be null)
-   * @return Operand
+   * @param operandList Child operands
+   * @param <R> Class of relational expression to match
+   * @return Operand that matches a relational expression that has no
+   *   children
    */
   public static <R extends RelNode> RelOptRuleOperand operand(
       Class<R> clazz,
@@ -111,7 +114,10 @@ public abstract class RelOptRule {
    *
    * @param clazz Class of relational expression to match (must not be null)
    * @param trait Trait to match, or null to match any trait
-   * @return Operand
+   * @param operandList Child operands
+   * @param <R> Class of relational expression to match
+   * @return Operand that matches a relational expression that has no
+   *   children
    */
   public static <R extends RelNode> RelOptRuleOperand operand(
       Class<R> clazz,
@@ -127,7 +133,11 @@ public abstract class RelOptRule {
    *
    * @param clazz Class of relational expression to match (must not be null)
    * @param trait Trait to match, or null to match any trait
-   * @return Operand
+   * @param predicate Additional match predicate
+   * @param operandList Child operands
+   * @param <R> Class of relational expression to match
+   * @return Operand that matches a relational expression that has a
+   *   particular trait and predicate
    */
   public static <R extends RelNode> RelOptRuleOperand operand(
       Class<R> clazz,
@@ -143,6 +153,10 @@ public abstract class RelOptRule {
    *
    * @param clazz Class of relational expression to match (must not be null)
    * @param trait Trait to match, or null to match any trait
+   * @param predicate Additional match predicate
+   * @param first First operand
+   * @param rest Rest operands
+   * @param <R> Class of relational expression to match
    * @return Operand
    */
   public static <R extends RelNode> RelOptRuleOperand operand(
@@ -167,7 +181,11 @@ public abstract class RelOptRule {
    * children, write <code>operand(clazz, any())</code></p>.
    *
    * @param clazz Class of relational expression to match (must not be null)
-   * @return Operand
+   * @param first First operand
+   * @param rest Rest operands
+   * @param <R> Class of relational expression to match
+   * @return Operand that matches a relational expression with a given
+   *   list of children
    */
   public static <R extends RelNode> RelOptRuleOperand operand(
       Class<R> clazz,
@@ -185,6 +203,8 @@ public abstract class RelOptRule {
    *
    * @param first First child operand
    * @param rest  Remaining child operands (may be empty)
+   * @return List of child operands that matches child relational
+   *   expressions in the order
    */
   public static RelOptRuleOperandChildren some(
       RelOptRuleOperand first,
@@ -219,6 +239,8 @@ public abstract class RelOptRule {
    *
    * @param first First child operand
    * @param rest  Remaining child operands (may be empty)
+   * @return List of child operands that matches child relational
+   *   expressions in any order
    */
   public static RelOptRuleOperandChildren unordered(
       RelOptRuleOperand first,
@@ -231,6 +253,8 @@ public abstract class RelOptRule {
 
   /**
    * Creates an empty list of child operands.
+   *
+   * @return Empty list of child operands
    */
   public static RelOptRuleOperandChildren none() {
     return RelOptRuleOperandChildren.LEAF_CHILDREN;
@@ -239,6 +263,9 @@ public abstract class RelOptRule {
   /**
    * Creates a list of child operands that signifies that the operand matches
    * any number of child relational expressions.
+   *
+   * @return List of child operands that signifies that the operand matches
+   *   any number of child relational expressions
    */
   public static RelOptRuleOperandChildren any() {
     return RelOptRuleOperandChildren.ANY_CHILDREN;
@@ -352,6 +379,9 @@ public abstract class RelOptRule {
    *
    * <p>The base implementation checks that the rules have the same class and
    * that the operands are equal; derived classes can override.
+   *
+   * @param that Another rule
+   * @return Whether this rule is equal to another rule
    */
   protected boolean equals(RelOptRule that) {
     // Include operands and class in the equality criteria just in case
@@ -420,6 +450,9 @@ public abstract class RelOptRule {
   /**
    * Returns the convention of the result of firing this rule, null if
    * not known.
+   *
+   * @return Convention of the result of firing this rule, null if
+   *   not known
    */
   public Convention getOutConvention() {
     return null;
@@ -428,12 +461,16 @@ public abstract class RelOptRule {
   /**
    * Returns the trait which will be modified as a result of firing this rule,
    * or null if the rule is not a converter rule.
+   *
+   * @return Trait which will be modified as a result of firing this rule,
+   *   or null if the rule is not a converter rule
    */
   public RelTrait getOutTrait() {
     return null;
   }
 
-  /** Returns the description of this rule.
+  /**
+   * Returns the description of this rule.
    *
    * <p>It must be unique (for rules that are not equal) and must consist of
    * only the characters A-Z, a-z, 0-9, '_', '.', '(', ')'. It must start with

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/plan/RelTrait.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelTrait.java b/core/src/main/java/org/apache/calcite/plan/RelTrait.java
index a3c3efe..ccbd963 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelTrait.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelTrait.java
@@ -62,6 +62,9 @@ public interface RelTrait {
    *
    * <p>Many traits cannot be substituted, in which case, this method should
    * return {@code equals(trait)}.</p>
+   *
+   * @param trait Given trait
+   * @return Whether this trait subsumes a given trait
    */
   boolean subsumes(RelTrait trait);
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
index d220dc4..a1f78d4 100644
--- a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
+++ b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
@@ -285,6 +285,7 @@ public abstract class AbstractRelNode implements RelNode {
    * methods for each input and attribute.
    *
    * @param pw Plan writer
+   * @return Plan writer for fluent-explain pattern
    */
   public RelWriter explainTerms(RelWriter pw) {
     return pw;
@@ -351,6 +352,8 @@ public abstract class AbstractRelNode implements RelNode {
 
   /**
    * Computes the digest. Does not modify this object.
+   *
+   * @return Digest
    */
   protected String computeDigest() {
     StringWriter sw = new StringWriter();

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/rel/RelNode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/RelNode.java b/core/src/main/java/org/apache/calcite/rel/RelNode.java
index 7f993f8..36e735e 100644
--- a/core/src/main/java/org/apache/calcite/rel/RelNode.java
+++ b/core/src/main/java/org/apache/calcite/rel/RelNode.java
@@ -84,6 +84,8 @@ public interface RelNode extends RelOptNode, Cloneable {
    * <p>The caller should treat the list as unmodifiable; typical
    * implementations will return an immutable list. If there are no
    * child expressions, returns an empty list, not <code>null</code>.
+   *
+   * @return List of this relational expression's child expressions
    */
   List<RexNode> getChildExps();
 
@@ -107,6 +109,8 @@ public interface RelNode extends RelOptNode, Cloneable {
   /**
    * Returns whether the same value will not come out twice. Default value is
    * <code>false</code>, derived classes should override.
+   *
+   * @return Whether the same value will not come out twice
    */
   boolean isDistinct();
 
@@ -119,9 +123,7 @@ public interface RelNode extends RelOptNode, Cloneable {
   RelNode getInput(int i);
 
   /**
-   * Returns the sub-query this relational expression belongs to. A sub-query
-   * determines the scope for correlating variables (see
-   * {@link #setCorrelVariable(String)}).
+   * Returns the sub-query this relational expression belongs to.
    *
    * @return Sub-query
    */
@@ -144,7 +146,9 @@ public interface RelNode extends RelOptNode, Cloneable {
 
   /**
    * Returns an array of this relational expression's inputs. If there are no
-   * inputs, returns an empty array, not <code>null</code>.
+   * inputs, returns an empty list, not {@code null}.
+   *
+   * @return Array of this relational expression's inputs
    */
   List<RelNode> getInputs();
 
@@ -155,6 +159,9 @@ public interface RelNode extends RelOptNode, Cloneable {
    * <p>NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use
    * {@link RelMetadataQuery#getRowCount}, which gives plugins a chance to
    * override the rel's default ideas about row count.
+   *
+   * @return Estimate of the number of rows this relational expression will
+   *   return
    */
   double getRows();
 
@@ -162,6 +169,11 @@ public interface RelNode extends RelOptNode, Cloneable {
    * Returns the names of variables which are set in this relational
    * expression but also used and therefore not available to parents of this
    * relational expression.
+   * <p>Note: only {@link org.apache.calcite.rel.core.Correlate} should set
+   * variables</p>
+   *
+   * @return Names of variables which are set in this relational
+   *   expression
    */
   Set<String> getVariablesStopped();
 
@@ -187,6 +199,9 @@ public interface RelNode extends RelOptNode, Cloneable {
    * Interacts with the {@link RelVisitor} in a
    * {@link org.apache.calcite.util.Glossary#VISITOR_PATTERN visitor pattern} to
    * traverse the tree of relational expressions.
+   *
+   * @param visitor Visitor that will traverse the tree of relational
+   *                expressions
    */
   void childrenAccept(RelVisitor visitor);
 
@@ -197,6 +212,9 @@ public interface RelNode extends RelOptNode, Cloneable {
    * <p>NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use
    * {@link RelMetadataQuery#getNonCumulativeCost}, which gives plugins a
    * chance to override the rel's default ideas about cost.
+   *
+   * @param planner Planner for cost calculation
+   * @return Cost of this plan (not including children)
    */
   RelOptCost computeSelfCost(RelOptPlanner planner);
 
@@ -227,17 +245,25 @@ public interface RelNode extends RelOptNode, Cloneable {
    * Receives notification that this expression is about to be registered. The
    * implementation of this method must at least register all child
    * expressions.
+   *
+   * @param planner Planner that plans this relational node
+   * @return Relational expression that should be used by the planner
    */
   RelNode onRegister(RelOptPlanner planner);
 
   /**
    * Computes the digest, assigns it, and returns it. For planner use only.
+   *
+   * @return Digest of this relational expression
    */
   String recomputeDigest();
 
   /**
    * Replaces the <code>ordinalInParent</code><sup>th</sup> input. You must
    * override this method if you override {@link #getInputs}.
+   *
+   * @param ordinalInParent Position of the child input, 0 is the first
+   * @param p New node that should be put at position {@code ordinalInParent}
    */
   void replaceInput(
       int ordinalInParent,
@@ -246,6 +272,9 @@ public interface RelNode extends RelOptNode, Cloneable {
   /**
    * If this relational expression represents an access to a table, returns
    * that table, otherwise returns null.
+   *
+   * @return If this relational expression represents an access to a table,
+   *   returns that table, otherwise returns null
    */
   RelOptTable getTable();
 
@@ -254,6 +283,9 @@ public interface RelNode extends RelOptNode, Cloneable {
    * name, for use in explain. For example, for a <code>
    * org.apache.calcite.rel.ArrayRel.ArrayReader</code>, this method returns
    * "ArrayReader".
+   *
+   * @return Name of this relational expression's class, sans package name,
+   *   for use in explain
    */
   String getRelTypeName();
 
@@ -280,6 +312,9 @@ public interface RelNode extends RelOptNode, Cloneable {
   /**
    * Returns a description of the physical ordering (or orderings) of this
    * relational expression. Never null.
+   *
+   * @return Description of the physical ordering (or orderings) of this
+   *   relational expression. Never null
    */
   List<RelCollation> getCollationList();
 
@@ -307,6 +342,9 @@ public interface RelNode extends RelOptNode, Cloneable {
    * relational expression of this class. The derived class should call
    * {@link org.apache.calcite.plan.RelOptPlanner#addRule} for each rule, and
    * then call {@code super.register}.</p>
+   *
+   * @param planner Planner to be used to register additional relational
+   *                expressions
    */
   void register(RelOptPlanner planner);
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/rel/convert/ConverterRule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/convert/ConverterRule.java b/core/src/main/java/org/apache/calcite/rel/convert/ConverterRule.java
index 55e243e..86fe1eb 100644
--- a/core/src/main/java/org/apache/calcite/rel/convert/ConverterRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/convert/ConverterRule.java
@@ -92,6 +92,9 @@ public abstract class ConverterRule extends RelOptRule {
    *
    * <p>The union-to-java converter, for example, is not guaranteed, because
    * it only works on unions.</p>
+   *
+   * @return {@code true} if this rule can convert <em>any</em> relational
+   *   expression
    */
   public boolean isGuaranteed() {
     return false;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java b/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
index 0072d4f..b795eb8 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
@@ -160,6 +160,18 @@ public abstract class Aggregate extends SingleRel {
 
   /** Creates a copy of this aggregate.
    *
+   * @param traitSet Traits
+   * @param input Input
+   * @param indicator Whether row type should include indicator fields to
+   *                 indicate which grouping set is active; must be true if
+   *                 aggregate is not simple
+   * @param groupSet Bit set of grouping fields
+   * @param groupSets List of all grouping sets; null for just {@code groupSet}
+   * @param aggCalls Collection of calls to aggregate functions
+   * @return New {@code Aggregate} if any parameter differs from the value of
+   *   this {@code Aggregate}, or just {@code this} if all the parameters are
+   *   the same
+   *
    * @see #copy(org.apache.calcite.plan.RelTraitSet, java.util.List)
    */
   public abstract Aggregate copy(RelTraitSet traitSet, RelNode input,
@@ -223,6 +235,8 @@ public abstract class Aggregate extends SingleRel {
 
   /**
    * Returns the list of grouping sets computed by this Aggregate.
+   *
+   * @return List of all grouping sets; null for just {@code groupSet}
    */
   public ImmutableList<ImmutableBitSet> getGroupSets() {
     return groupSets;
@@ -270,7 +284,19 @@ public abstract class Aggregate extends SingleRel {
         indicator, groupSet, groupSets, aggCalls);
   }
 
-  /** Computes the row type of an {@code Aggregate} before it exists. */
+  /**
+   * Computes the row type of an {@code Aggregate} before it exists.
+   *
+   * @param typeFactory Type factory
+   * @param inputRowType Input row type
+   * @param indicator Whether row type should include indicator fields to
+   *                 indicate which grouping set is active; must be true if
+   *                 aggregate is not simple
+   * @param groupSet Bit set of grouping fields
+   * @param groupSets List of all grouping sets; null for just {@code groupSet}
+   * @param aggCalls Collection of calls to aggregate functions
+   * @return Row type of the aggregate
+   */
   public static RelDataType deriveRowType(RelDataTypeFactory typeFactory,
       final RelDataType inputRowType, boolean indicator,
       ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets,
@@ -326,6 +352,8 @@ public abstract class Aggregate extends SingleRel {
 
   /**
    * Returns whether any of the aggregates are DISTINCT.
+   *
+   * @return Whether any of the aggregates are DISTINCT
    */
   public boolean containsDistinctCall() {
     for (AggregateCall call : aggCalls) {
@@ -336,7 +364,11 @@ public abstract class Aggregate extends SingleRel {
     return false;
   }
 
-  /** Returns the type of roll-up. */
+  /**
+   * Returns the type of roll-up.
+   *
+   * @return Type of roll-up
+   */
   public Group getGroupType() {
     return Group.induce(groupSet, groupSets);
   }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/rel/core/Calc.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Calc.java b/core/src/main/java/org/apache/calcite/rel/core/Calc.java
index 803c783..e337b7a 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Calc.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Calc.java
@@ -47,6 +47,17 @@ public abstract class Calc extends SingleRel {
 
   //~ Constructors -----------------------------------------------------------
 
+  /**
+   * Creates calc node.
+   *
+   * @param cluster Cluster
+   * @param traits Traits
+   * @param child Input relation
+   * @param rowType Output row type
+   * @param program Calc program
+   * @param collationList Description of the physical ordering (or orderings)
+   *                      of this relational expression. Never null
+   */
   protected Calc(
       RelOptCluster cluster,
       RelTraitSet traits,
@@ -67,7 +78,19 @@ public abstract class Calc extends SingleRel {
     return copy(traitSet, sole(inputs), program, collationList);
   }
 
-  /** Creates a copy of this {@code Calc}. */
+  /**
+   * Creates a copy of this {@code Calc}.
+   *
+   * @param traitSet Traits
+   * @param child Input relation
+   * @param program Calc program
+   * @param collationList Description of the physical ordering (or orderings)
+   *                      of this relational expression. Never null
+   * @return New {@code Calc} if any parameter differs from the value of this
+   *   {@code Calc}, or just {@code this} if all the parameters are the same
+
+   * @see #copy(org.apache.calcite.plan.RelTraitSet, java.util.List)
+   */
   public abstract Calc copy(
       RelTraitSet traitSet,
       RelNode child,

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/rel/core/Correlate.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Correlate.java b/core/src/main/java/org/apache/calcite/rel/core/Correlate.java
index 37edda9..68cbb9e 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Correlate.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Correlate.java
@@ -37,24 +37,28 @@ import java.util.Set;
 
 /**
  * A relational operator that performs nested-loop joins.
- * <p/>
+ *
  * <p>It behaves like a kind of {@link org.apache.calcite.rel.core.Join},
  * but works by setting variables in its environment and restarting its
  * right-hand input.
- * <p/>
+ *
  * <p>Correlate is not a join since: typical rules should not match Correlate.
- * <p/>
+ *
  * <p>A Correlate is used to represent a correlated query. One
  * implementation strategy is to de-correlate the expression.
  *
- * NestedLoops     -> Correlate(A, B, regular)
- * NestedLoopsOuter-> Correlate(A, B, outer)
- * NestedLoopsSemi -> Correlate(A, B, semi)
- * NestedLoopsAnti -> Correlate(A, B, anti)
- * HashJoin        -> EquiJoin(A, B)
- * HashJoinOuter   -> EquiJoin(A, B)
- * HashJoinSemi    -> SemiJoin(A, B, semi)
- * HashJoinAnti    -> SemiJoin(A, B, anti)
+ * <table>
+ *   <caption>Mapping of physical operations to logical ones</caption>
+ *   <tr><th>Physical operation</th><th>Logical operation</th></tr>
+ *   <tr><td>NestedLoops</td><td>Correlate(A, B, regular)</td></tr>
+ *   <tr><td>NestedLoopsOuter</td><td>Correlate(A, B, outer)</td></tr>
+ *   <tr><td>NestedLoopsSemi</td><td>Correlate(A, B, semi)</td></tr>
+ *   <tr><td>NestedLoopsAnti</td><td>Correlate(A, B, anti)</td></tr>
+ *   <tr><td>HashJoin</td><td>EquiJoin(A, B)</td></tr>
+ *   <tr><td>HashJoinOuter</td><td>EquiJoin(A, B, outer)</td></tr>
+ *   <tr><td>HashJoinSemi</td><td>SemiJoin(A, B, semi)</td></tr>
+ *   <tr><td>HashJoinAnti</td><td>SemiJoin(A, B, anti)</td></tr>
+ * </table>
  *
  * @see CorrelationId
  */
@@ -69,12 +73,12 @@ public abstract class Correlate extends BiRel {
 
   /**
    * Creates a Correlate.
-   * @param cluster      cluster this relational expression belongs to
-   * @param left         left input relational expression
-   * @param right        right input relational expression
-   * @param correlationId variable name for the row of left input
-   * @param requiredColumns
-   * @param joinType join type
+   * @param cluster      Cluster this relational expression belongs to
+   * @param left         Left input relational expression
+   * @param right        Right input relational expression
+   * @param correlationId Variable name for the row of left input
+   * @param requiredColumns Set of columns that are used by correlation
+   * @param joinType Join type
    */
   protected Correlate(
       RelOptCluster cluster,
@@ -91,6 +95,8 @@ public abstract class Correlate extends BiRel {
 
   /**
    * Creates a Correlate by parsing serialized output.
+   *
+   * @param input Input representation
    */
   public Correlate(RelInput input) {
     this(

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/rel/core/Join.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Join.java b/core/src/main/java/org/apache/calcite/rel/core/Join.java
index ae73eb8..9405a6e 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Join.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Join.java
@@ -343,6 +343,7 @@ public abstract class Join extends BiRel {
    *
    * <p>General contract as {@link RelNode#copy}.
    *
+   * @param traitSet      Traits
    * @param conditionExpr Condition
    * @param left          Left input
    * @param right         Right input
@@ -354,7 +355,11 @@ public abstract class Join extends BiRel {
   public abstract Join copy(RelTraitSet traitSet, RexNode conditionExpr,
       RelNode left, RelNode right, JoinRelType joinType, boolean semiJoinDone);
 
-  /** Analyzes the join condition. */
+  /**
+   * Analyzes the join condition.
+   *
+   * @return Analyzed join condition
+   */
   public JoinInfo analyzeCondition() {
     return JoinInfo.of(left, right, condition);
   }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/rel/core/Project.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Project.java b/core/src/main/java/org/apache/calcite/rel/core/Project.java
index 7ff2cc4..9032ca3 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Project.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Project.java
@@ -123,9 +123,19 @@ public abstract class Project extends SingleRel {
     return copy(traitSet, sole(inputs), exps, rowType);
   }
 
-  /** Copies a project.
+  /**
+   * Copies a project.
+   *
+   * @param traitSet Traits
+   * @param input Input
+   * @param exps Project expressions
+   * @param rowType Output row type
+   * @return New {@code Project} if any parameter differs from the value of this
+   *   {@code Project}, or just {@code this} if all the parameters are
+   *   the same
    *
-   * @see #copy(RelTraitSet, List) */
+   * @see #copy(RelTraitSet, List)
+   */
   public abstract Project copy(RelTraitSet traitSet, RelNode input,
       List<RexNode> exps, RelDataType rowType);
 
@@ -143,6 +153,8 @@ public abstract class Project extends SingleRel {
 
   /**
    * Returns the project expressions.
+   *
+   * @return Project expressions
    */
   public List<RexNode> getProjects() {
     return exps;
@@ -151,6 +163,8 @@ public abstract class Project extends SingleRel {
   /**
    * Returns a list of (expression, name) pairs. Convenient for various
    * transformations.
+   *
+   * @return List of (expression, name) pairs
    */
   public final List<Pair<RexNode, String>> getNamedProjects() {
     return Pair.zip(getProjects(), getRowType().getFieldNames());
@@ -260,6 +274,8 @@ public abstract class Project extends SingleRel {
 
   /**
    * Returns a mapping, or null if this projection is not a mapping.
+   *
+   * @return Mapping, or null if this projection is not a mapping
    */
   public Mappings.TargetMapping getMapping() {
     return getMapping(getInput().getRowType().getFieldCount(), exps);
@@ -276,6 +292,7 @@ public abstract class Project extends SingleRel {
    *
    * @param inputFieldCount Number of input fields
    * @param projects Project expressions
+   * @return Mapping of a set of project expressions
    */
   public static Mappings.TargetMapping getMapping(int inputFieldCount,
       List<RexNode> projects) {
@@ -294,6 +311,9 @@ public abstract class Project extends SingleRel {
   /**
    * Returns a permutation, if this projection is merely a permutation of its
    * input fields, otherwise null.
+   *
+   * @return Permutation, if this projection is merely a permutation of its
+   *   input fields, otherwise null
    */
   public Permutation getPermutation() {
     final int fieldCount = rowType.getFieldList().size();

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/rel/core/SetOp.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/SetOp.java b/core/src/main/java/org/apache/calcite/rel/core/SetOp.java
index 1c464d6..e99c66d 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/SetOp.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/SetOp.java
@@ -125,6 +125,8 @@ public abstract class SetOp extends AbstractRelNode {
    *
    * @param compareNames Whether column names are important in the
    *                     homogeneity comparison
+   * @return Whether all the inputs of this set operator have the same row
+   *   type as its output row
    */
   public boolean isHomogeneous(boolean compareNames) {
     RelDataType unionType = getRowType();

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactory.java b/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactory.java
index 16520a7..35272c8 100644
--- a/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactory.java
+++ b/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactory.java
@@ -43,6 +43,8 @@ public interface RelDataTypeFactory {
 
   /**
    * Returns the type system.
+   *
+   * @return Type system
    */
   RelDataTypeSystem getTypeSystem();
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/schema/Schema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/Schema.java b/core/src/main/java/org/apache/calcite/schema/Schema.java
index 0c46117..2f374d8 100644
--- a/core/src/main/java/org/apache/calcite/schema/Schema.java
+++ b/core/src/main/java/org/apache/calcite/schema/Schema.java
@@ -63,6 +63,8 @@ public interface Schema {
 
   /**
    * Returns the names of the tables in this schema.
+   *
+   * @return Names of the tables in this schema
    */
   Set<String> getTableNames();
 
@@ -77,16 +79,23 @@ public interface Schema {
 
   /**
    * Returns the names of the functions in this schema.
+   *
+   * @return Names of the functions in this schema
    */
   Set<String> getFunctionNames();
 
   /**
    * Returns a sub-schema with a given name, or null.
+   *
+   * @param name Sub-schema name
+   * @return Sub-schema with a given name, or null
    */
   Schema getSubSchema(String name);
 
   /**
    * Returns the names of this schema's child schemas.
+   *
+   * @return Names of this schema's child schemas
    */
   Set<String> getSubSchemaNames();
 
@@ -96,6 +105,7 @@ public interface Schema {
    *
    * @param parentSchema Parent schema
    * @param name Name of this schema
+   * @return Expression by which this schema can be referenced in generated code
    */
   Expression getExpression(SchemaPlus parentSchema, String name);
 
@@ -104,7 +114,11 @@ public interface Schema {
    * by methods such as {@link #getTable(String)}.
    *
    * <p>Even if this method returns true, the maps are not modified. Calcite
-   * stores the defined objects in a wrapper object. */
+   * stores the defined objects in a wrapper object.
+   *
+   * @return Whether the user is allowed to create new tables, functions
+   *   and sub-schemas in this schema
+   */
   boolean isMutable();
 
   /** Returns whether the contents of this schema have changed since a given

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/schema/SchemaFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/SchemaFactory.java b/core/src/main/java/org/apache/calcite/schema/SchemaFactory.java
index b2a78b2..57f5b4b 100644
--- a/core/src/main/java/org/apache/calcite/schema/SchemaFactory.java
+++ b/core/src/main/java/org/apache/calcite/schema/SchemaFactory.java
@@ -66,6 +66,7 @@ public interface SchemaFactory {
    * @param parentSchema Parent schema
    * @param name Name of this schema
    * @param operand The "operand" JSON property
+   * @return Created schema
    */
   Schema create(
       SchemaPlus parentSchema,

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/7eb1bfdb/core/src/main/java/org/apache/calcite/schema/impl/AbstractSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/impl/AbstractSchema.java b/core/src/main/java/org/apache/calcite/schema/impl/AbstractSchema.java
index ca3389b..e917b6e 100644
--- a/core/src/main/java/org/apache/calcite/schema/impl/AbstractSchema.java
+++ b/core/src/main/java/org/apache/calcite/schema/impl/AbstractSchema.java
@@ -75,6 +75,8 @@ public class AbstractSchema implements Schema {
    * and {@link #getTable(String)} depend on this map.
    * The default implementation of this method returns the empty map.
    * Override this method to change their behavior.</p>
+   *
+   * @return Map of tables in this schema by name
    */
   protected Map<String, Table> getTableMap() {
     return ImmutableMap.of();
@@ -98,6 +100,8 @@ public class AbstractSchema implements Schema {
    * and {@link Schema#getFunctions(String)} depend on this map.
    * The default implementation of this method returns the empty multi-map.
    * Override this method to change their behavior.</p>
+   *
+   * @return Multi-map of functions in this schema by name
    */
   protected Multimap<String, Function> getFunctionMultimap() {
     return ImmutableMultimap.of();
@@ -112,12 +116,14 @@ public class AbstractSchema implements Schema {
   }
 
   /**
-   * Returns a map of tables in this schema by name.
+   * Returns a map of sub-schemas in this schema by name.
    *
-   * <p>The implementations of {@link #getTableNames()}
-   * and {@link #getTable(String)} depend on this map.
+   * <p>The implementations of {@link #getSubSchemaNames()}
+   * and {@link #getSubSchema(String)} depend on this map.
    * The default implementation of this method returns the empty map.
    * Override this method to change their behavior.</p>
+   *
+   * @return Map of sub-schemas in this schema by name
    */
   protected Map<String, Schema> getSubSchemaMap() {
     return ImmutableMap.of();


[2/2] incubator-calcite git commit: [CALCITE-506] Update EnumerableRelImplementor.stash so it is suitable for all kinds of classes

Posted by vl...@apache.org.
[CALCITE-506] Update EnumerableRelImplementor.stash so it is suitable for all kinds of classes


Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/b7427ed7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/b7427ed7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/b7427ed7

Branch: refs/heads/master
Commit: b7427ed741b1ab20a3d919b618a6f2eaef0b275a
Parents: 7eb1bfd
Author: Vladimir Sitnikov <si...@gmail.com>
Authored: Sat Dec 13 14:23:55 2014 +0300
Committer: Vladimir Sitnikov <si...@gmail.com>
Committed: Sat Dec 13 14:23:55 2014 +0300

----------------------------------------------------------------------
 .../enumerable/EnumerableRelImplementor.java    | 83 ++++++++++++++++----
 1 file changed, 66 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/b7427ed7/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRelImplementor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRelImplementor.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRelImplementor.java
index 436eb4e..2a3ca20 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRelImplementor.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRelImplementor.java
@@ -19,7 +19,6 @@ package org.apache.calcite.adapter.enumerable;
 import org.apache.calcite.DataContext;
 import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
 import org.apache.calcite.linq4j.Enumerable;
-import org.apache.calcite.linq4j.Queryable;
 import org.apache.calcite.linq4j.function.Function1;
 import org.apache.calcite.linq4j.tree.BlockBuilder;
 import org.apache.calcite.linq4j.tree.BlockStatement;
@@ -35,14 +34,16 @@ import org.apache.calcite.linq4j.tree.NewArrayExpression;
 import org.apache.calcite.linq4j.tree.NewExpression;
 import org.apache.calcite.linq4j.tree.ParameterExpression;
 import org.apache.calcite.linq4j.tree.Primitive;
+import org.apache.calcite.linq4j.tree.Statement;
 import org.apache.calcite.linq4j.tree.Types;
 import org.apache.calcite.linq4j.tree.Visitor;
-import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rex.RexBuilder;
 import org.apache.calcite.runtime.Bindable;
 import org.apache.calcite.runtime.Utilities;
 import org.apache.calcite.util.BuiltInMethod;
 
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
@@ -51,6 +52,7 @@ import java.io.Serializable;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -64,6 +66,8 @@ public class EnumerableRelImplementor extends JavaRelImplementor {
   public final Map<String, Object> map;
   private final Map<String, RexToLixTranslator.InputGetter> corrVars =
       Maps.newHashMap();
+  private final Map<Object, ParameterExpression> stashedParameters =
+      Maps.newIdentityHashMap();
 
   protected final Function1<String, RexToLixTranslator.InputGetter>
   allCorrelateVariables =
@@ -103,11 +107,27 @@ public class EnumerableRelImplementor extends JavaRelImplementor {
     // directly from inner classes.
     final ParameterExpression root0_ =
         Expressions.parameter(Modifier.FINAL, DataContext.class, "root0");
+
+    // This creates the following code
+    // final Integer v1stashed = (Integer) root.get("v1stashed")
+    // It is convenient for passing non-literal "compile-time" constants
+    final Collection<Statement> stashed =
+        Collections2.transform(stashedParameters.values(),
+            new Function<ParameterExpression, Statement>() {
+              public Statement apply(ParameterExpression input) {
+                return Expressions.declare(Modifier.FINAL, input,
+                    Expressions.convert_(Expressions.call(DataContext.ROOT,
+                        BuiltInMethod.DATA_CONTEXT_GET.method,
+                        Expressions.constant(input.name)), input.type));
+              }
+            });
+
     final BlockStatement block = Expressions.block(
         Iterables.concat(
             ImmutableList.of(
                 Expressions.statement(
                     Expressions.assign(DataContext.ROOT, root0_))),
+            stashed,
             result.block.statements));
     memberDeclarations.add(
         Expressions.fieldDecl(0, DataContext.ROOT, null));
@@ -379,21 +399,50 @@ public class EnumerableRelImplementor extends JavaRelImplementor {
     return classDeclaration;
   }
 
-  public Expression register(Queryable queryable) {
-    return register(queryable, queryable.getClass());
-  }
-
-  public ParameterExpression register(Object o, Class clazz) {
-    final String name = "v" + map.size();
-    map.put(name, o);
-    return Expressions.variable(clazz, name);
-  }
-
-  public Expression stash(RelNode child, Class clazz) {
-    final ParameterExpression x = register(child, clazz);
-    final Expression e = Expressions.call(getRootExpression(),
-        BuiltInMethod.DATA_CONTEXT_GET.method, Expressions.constant(x.name));
-    return Expressions.convert_(e, clazz);
+  /**
+   * Stashes a value for the executor. Given values are de-duplicated if
+   * identical (see {@link java.util.IdentityHashMap}).
+   *
+   * <p>For instance, to pass {@code ArrayList} to your method, you can use
+   * {@code Expressions.call(method, implementor.stash(arrayList))}.
+   *
+   * <p>For simple literals (strings, numbers) the result is equivalent to
+   * {@link org.apache.calcite.linq4j.tree.Expressions#constant(Object, java.lang.reflect.Type)}.
+   *
+   * <p>Note: the input value is held in memory as long as the statement
+   * is alive. If you are using just a subset of its content, consider creating
+   * a slimmer holder.
+   *
+   * @param input Value to be stashed
+   * @param clazz Java class type of the value when it is used
+   * @param <T> Java class type of the value when it is used
+   * @return Expression that will represent {@code input} in runtime
+   */
+  public <T> Expression stash(T input, Class<? super T> clazz) {
+    // Well-known final classes that can be used as literals
+    if (input == null
+        || input instanceof String
+        || input instanceof Boolean
+        || input instanceof Byte
+        || input instanceof Short
+        || input instanceof Integer
+        || input instanceof Long
+        || input instanceof Float
+        || input instanceof Double
+        ) {
+      return Expressions.constant(input, clazz);
+    }
+    ParameterExpression cached = stashedParameters.get(input);
+    if (cached != null) {
+      return cached;
+    }
+    // "stashed" avoids name clash since this name will be used as the variable
+    // name at the very start of the method.
+    final String name = "v" + map.size() + "stashed";
+    final ParameterExpression x = Expressions.variable(clazz, name);
+    map.put(name, input);
+    stashedParameters.put(input, x);
+    return x;
   }
 
   public void registerCorrelVariable(final String name,