Class RelOptRuleCall
- java.lang.Object
-
- org.apache.calcite.plan.RelOptRuleCall
-
- Direct Known Subclasses:
HepRuleCall
,VolcanoRuleCall
public abstract class RelOptRuleCall extends java.lang.Object
ARelOptRuleCall
is an invocation of aRelOptRule
with a set ofrelational expression
s as arguments.
-
-
Field Summary
Fields Modifier and Type Field Description int
id
protected static org.slf4j.Logger
LOGGER
private static int
nextId
Generator forid
values.protected java.util.Map<RelNode,java.util.List<RelNode>>
nodeInputs
protected RelOptRuleOperand
operand0
private java.util.List<RelNode>
parents
private RelOptPlanner
planner
RelNode[]
rels
RelOptRule
rule
-
Constructor Summary
Constructors Modifier Constructor Description protected
RelOptRuleCall(RelOptPlanner planner, RelOptRuleOperand operand, RelNode[] rels, java.util.Map<RelNode,java.util.List<RelNode>> nodeInputs)
protected
RelOptRuleCall(RelOptPlanner planner, RelOptRuleOperand operand, RelNode[] rels, java.util.Map<RelNode,java.util.List<RelNode>> nodeInputs, java.util.List<RelNode> parents)
Creates a RelOptRuleCall.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RelBuilder
builder()
Creates aRelBuilder
to be used by code within the call.java.util.List<RelNode>
getChildRels(RelNode rel)
Returns the children of a given relational expression node matched in a rule.RelMetadataQuery
getMetadataQuery()
Returns the current RelMetadataQuery, to be used for instance byRelOptRule.onMatch(RelOptRuleCall)
.RelOptRuleOperand
getOperand0()
Returns the root operand matched by this rule.java.util.List<RelNode>
getParents()
RelOptPlanner
getPlanner()
Returns the planner.java.util.List<RelNode>
getRelList()
Returns a list of matched relational expressions.RelNode[]
getRels()
Deprecated.UsegetRelList()
orrel(int)
RelOptRule
getRule()
Returns the invoked planner rule.<T extends RelNode>
Trel(int ordinal)
Retrieves theordinal
th matched relational expression.protected void
setChildRels(RelNode rel, java.util.List<RelNode> inputs)
Assigns the input relational expressions of a given relational expression, as seen by this particular call.void
transformTo(RelNode rel)
Registers that a rule has produced an equivalent relational expression, but no other equivalences.abstract void
transformTo(RelNode rel, java.util.Map<RelNode,RelNode> equiv)
Registers that a rule has produced an equivalent relational expression.
-
-
-
Field Detail
-
LOGGER
protected static final org.slf4j.Logger LOGGER
-
nextId
private static int nextId
Generator forid
values.
-
id
public final int id
-
operand0
protected final RelOptRuleOperand operand0
-
rule
public final RelOptRule rule
-
rels
public final RelNode[] rels
-
planner
private final RelOptPlanner planner
-
parents
private final java.util.List<RelNode> parents
-
-
Constructor Detail
-
RelOptRuleCall
protected RelOptRuleCall(RelOptPlanner planner, RelOptRuleOperand operand, RelNode[] rels, java.util.Map<RelNode,java.util.List<RelNode>> nodeInputs, java.util.List<RelNode> parents)
Creates a RelOptRuleCall.- Parameters:
planner
- Planneroperand
- Root operandrels
- Array of relational expressions which matched each operandnodeInputs
- For each node which matched withmatchAnyChildren
=true, a list of the node's inputsparents
- 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, java.util.Map<RelNode,java.util.List<RelNode>> nodeInputs)
-
-
Method Detail
-
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.UsegetRelList()
orrel(int)
Returns a list of matched relational expressions.- Returns:
- matched relational expressions
-
getRelList
public java.util.List<RelNode> getRelList()
Returns a list of matched relational expressions.- Returns:
- matched relational expressions
- See Also:
rel(int)
-
rel
public <T extends RelNode> T rel(int ordinal)
Retrieves theordinal
th matched relational expression. This corresponds to theordinal
th operand of the rule.- Type Parameters:
T
- Type- Parameters:
ordinal
- Ordinal- Returns:
- Relational expression
-
getChildRels
public java.util.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 thegetRelList()
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.- Parameters:
rel
- Relational expression- Returns:
- Children of relational expression
-
setChildRels
protected void setChildRels(RelNode rel, java.util.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 isRelOptRule.any()
.
-
getPlanner
public RelOptPlanner getPlanner()
Returns the planner.- Returns:
- planner
-
getMetadataQuery
public RelMetadataQuery getMetadataQuery()
Returns the current RelMetadataQuery, to be used for instance byRelOptRule.onMatch(RelOptRuleCall)
.
-
getParents
public java.util.List<RelNode> getParents()
- Returns:
- list of parents of the first relational expression
-
transformTo
public abstract void transformTo(RelNode rel, java.util.Map<RelNode,RelNode> equiv)
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 byrel.getTraits()
will be copied fromthis.rels[0].getTraitSet()
.- 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.- Parameters:
rel
- Relational expression equivalent to the root relational expression of the rule call,call.rels(0)
-
builder
public RelBuilder builder()
Creates aRelBuilder
to be used by code within the call. TheRelOptRule.relBuilderFactory
argument contains policies such as what implementation ofFilter
to create.
-
-