Class RelOptRuleCall

java.lang.Object
org.apache.calcite.plan.RelOptRuleCall
Direct Known Subclasses:
HepRuleCall, VolcanoRuleCall

public abstract class RelOptRuleCall extends Object
A RelOptRuleCall is an invocation of a RelOptRule with a set of relational expressions as arguments.
  • Field Details

  • Constructor Details

    • RelOptRuleCall

      protected RelOptRuleCall(RelOptPlanner planner, RelOptRuleOperand operand, RelNode[] rels, Map<RelNode,List<RelNode>> nodeInputs, @Nullable List<RelNode> parents)
      Creates a RelOptRuleCall.
      Parameters:
      planner - Planner
      operand - Root operand
      rels - Array of relational expressions which matched each operand
      nodeInputs - For each node which matched with matchAnyChildren=true, a list of the node's inputs
      parents - list of parent RelNodes corresponding to the first relational expression in the array argument, if known; otherwise, null
    • RelOptRuleCall

      protected RelOptRuleCall(RelOptPlanner planner, RelOptRuleOperand operand, RelNode[] rels, Map<RelNode,List<RelNode>> nodeInputs)
  • Method Details

    • getOperand0

      public RelOptRuleOperand getOperand0()
      Returns the root operand matched by this rule.
      Returns:
      root operand
    • getRule

      public RelOptRule getRule()
      Returns the invoked planner rule.
      Returns:
      planner rule
    • getRels

      @Deprecated public RelNode[] getRels()
      Deprecated.
      Returns a list of matched relational expressions.
      Returns:
      matched relational expressions
    • getRelList

      public List<RelNode> getRelList()
      Returns a list of matched relational expressions.
      Returns:
      matched relational expressions
      See Also:
    • rel

      public <T extends RelNode> T rel(int ordinal)
      Retrieves the ordinalth matched relational expression. This corresponds to the ordinalth operand of the rule.
      Type Parameters:
      T - Type
      Parameters:
      ordinal - Ordinal
      Returns:
      Relational expression
    • getChildRels

      public @Nullable List<RelNode> getChildRels(RelNode rel)
      Returns the children of a given relational expression node matched in a rule.

      If the policy of the operand which caused the match is not RelOptRuleOperandChildPolicy.ANY, the children will have their own operands and therefore be easily available in the array returned by the getRelList() method, so this method returns null.

      This method is for RelOptRuleOperandChildPolicy.ANY, which is generally used when a node can have a variable number of children, and hence where the matched children are not retrievable by any other means.

      Warning: it produces wrong result for unordered(...) case.

      Parameters:
      rel - Relational expression
      Returns:
      Children of relational expression
    • setChildRels

      protected void setChildRels(RelNode rel, List<RelNode> inputs)
      Assigns the input relational expressions of a given relational expression, as seen by this particular call. Is only called when the operand is any.
    • getPlanner

      public RelOptPlanner getPlanner()
      Returns the planner.
      Returns:
      planner
    • isRuleExcluded

      public boolean isRuleExcluded()
      Determines whether the rule is excluded by any root node hint.
      Returns:
      true iff rule should be excluded
    • getMetadataQuery

      public RelMetadataQuery getMetadataQuery()
      Returns the current RelMetadataQuery to be used for instance by RelOptRule.onMatch(RelOptRuleCall).
    • getParents

      public @Nullable List<RelNode> getParents()
      Returns a list of parents of the first relational expression.
    • transformTo

      public abstract void transformTo(RelNode rel, Map<RelNode,RelNode> equiv, RelHintsPropagator handler)
      Registers that a rule has produced an equivalent relational expression.

      Called by the rule whenever it finds a match. The implementation of this method guarantees that the original relational expression (that is, this.rels[0]) has its traits propagated to the new relational expression (rel) and its unregistered children. Any trait not specifically set in the RelTraitSet returned by rel.getTraits() will be copied from this.rels[0].getTraitSet().

      The hints of the root relational expression of the rule call(this.rels[0]) are copied to the new relational expression(rel) with specified handler handler.

      Parameters:
      rel - Relational expression equivalent to the root relational expression of the rule call, call.rels(0)
      equiv - Map of other equivalences
      handler - Handler to customize the relational expression that registers into the planner, the first parameter is the root relational expression and the second parameter is the new relational expression
    • transformTo

      public void transformTo(RelNode rel, Map<RelNode,RelNode> equiv)
      Registers that a rule has produced an equivalent relational expression, with specified equivalences.

      The hints are copied with filter strategies from the root relational expression of the rule call(this.rels[0]) to the new relational expression(rel).

      Parameters:
      rel - Relational expression equivalent to the root relational expression of the rule call, call.rels(0)
      equiv - Map of other equivalences
    • transformTo

      public final void transformTo(RelNode rel)
      Registers that a rule has produced an equivalent relational expression, but no other equivalences.

      The hints are copied with filter strategies from the root relational expression of the rule call(this.rels[0]) to the new relational expression(rel).

      Parameters:
      rel - Relational expression equivalent to the root relational expression of the rule call, call.rels(0)
    • transformTo

      public final void transformTo(RelNode rel, RelHintsPropagator handler)
      Registers that a rule has produced an equivalent relational expression, but no other equivalences.

      The hints of the root relational expression of the rule call(this.rels[0]) are copied to the new relational expression(rel) with specified handler handler.

      Parameters:
      rel - Relational expression equivalent to the root relational expression of the rule call, call.rels(0)
      handler - Handler to customize the relational expression that registers into the planner, the first parameter is the root relational expression and the second parameter is the new relational expression
    • builder

      public RelBuilder builder()
      Creates a RelBuilder to be used by code within the call. The RelOptRule.relBuilderFactory argument contains policies such as what implementation of Filter to create.