public abstract class AbstractRelNode extends Object implements RelNode
RelNode).RelNode.Context| Modifier and Type | Field and Description |
|---|---|
protected RelDigest |
digest
The digest that uniquely identifies the node.
|
protected int |
id
Unique id of this object, for debugging.
|
protected @MonotonicNonNull RelDataType |
rowType
Cached type of this relational expression.
|
protected RelTraitSet |
traitSet
RelTraitSet that describes the traits of this RelNode.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractRelNode(RelOptCluster cluster,
RelTraitSet traitSet)
Creates an
AbstractRelNode. |
| Modifier and Type | Method and Description |
|---|---|
RelNode |
accept(RelShuttle shuttle)
Accepts a visit from a shuttle.
|
RelNode |
accept(RexShuttle shuttle)
Accepts a visit from a shuttle.
|
void |
childrenAccept(RelVisitor visitor)
Interacts with the
RelVisitor in a
visitor pattern to
traverse the tree of relational expressions. |
void |
collectVariablesSet(Set<CorrelationId> variableSet)
Collects variables set by this expression.
|
void |
collectVariablesUsed(Set<CorrelationId> variableSet)
Collects variables known to be used by this expression or its
descendants.
|
@Nullable RelOptCost |
computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq)
Returns the cost of this plan (not including children).
|
RelNode |
copy(RelTraitSet traitSet,
List<RelNode> inputs)
Creates a copy of this relational expression, perhaps changing traits and
inputs.
|
boolean |
deepEquals(@Nullable Object obj)
Equality check for RelNode digest.
|
int |
deepHashCode()
Compute hash code for RelNode digest.
|
protected RelDataType |
deriveRowType() |
boolean |
equals(@Nullable Object obj) |
double |
estimateRowCount(RelMetadataQuery mq)
Returns an estimate of the number of rows this relational expression will
return.
|
void |
explain(RelWriter pw)
Describes the inputs and attributes of this relational expression.
|
RelWriter |
explainTerms(RelWriter pw)
Describes the inputs and attributes of this relational expression.
|
RelOptCluster |
getCluster()
Returns the cluster this relational expression belongs to.
|
@Nullable Convention |
getConvention()
Return the CallingConvention trait from this RelNode's
trait set. |
@Nullable String |
getCorrelVariable()
Returns the name of the variable which is to be implicitly set at runtime
each time a row is returned from the first input of this relational
expression; or null if there is no variable.
|
String |
getDescription()
Deprecated.
|
String |
getDigest()
Returns a digest string of this
RelNode. |
RelDataType |
getExpectedInputRowType(int ordinalInParent)
Returns the type of the rows expected for an input.
|
int |
getId()
Returns the ID of this relational expression, unique among all relational
expressions created since the server was started.
|
RelNode |
getInput(int i)
Returns the
ith input relational expression. |
List<RelNode> |
getInputs()
Returns an array of this relational expression's inputs.
|
RelDigest |
getRelDigest()
Returns a digest of this
RelNode. |
String |
getRelTypeName()
Returns the name of this relational expression's class, sans package
name, for use in explain.
|
RelDataType |
getRowType()
Returns the type of the rows returned by this relational expression.
|
@Nullable RelOptTable |
getTable()
If this relational expression represents an access to a table, returns
that table, otherwise returns null.
|
RelTraitSet |
getTraitSet()
Retrieves this RelNode's traits.
|
Set<CorrelationId> |
getVariablesSet()
Returns the variables that are set in this relational
expression but also used and therefore not available to parents of this
relational expression.
|
int |
hashCode() |
boolean |
isEnforcer()
Indicates whether it is an enforcer operator, e.g.
|
boolean |
isValid(Litmus litmus,
@Nullable RelNode.Context context)
Returns whether this relational expression is valid.
|
<M extends Metadata> |
metadata(Class<M> metadataClass,
RelMetadataQuery mq)
Deprecated.
|
RelNode |
onRegister(RelOptPlanner planner)
Receives notification that this expression is about to be registered.
|
void |
recomputeDigest()
Recomputes the digest.
|
void |
register(RelOptPlanner planner)
Registers any special rules specific to this kind of relational
expression.
|
void |
replaceInput(int ordinalInParent,
RelNode p)
Replaces the
ordinalInParentth input. |
protected static <T> T |
sole(List<T> collection) |
String |
toString()
Description; consists of id plus digest.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitexplain, fieldIsNullableprotected @MonotonicNonNull RelDataType rowType
@API(since="1.24",
status=INTERNAL)
protected RelDigest digest
protected final int id
protected RelTraitSet traitSet
protected AbstractRelNode(RelOptCluster cluster, RelTraitSet traitSet)
AbstractRelNode.public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs)
RelNodeSub-classes with other important attributes are encouraged to create variants of this method with more parameters.
protected static <T> T sole(List<T> collection)
public final RelOptCluster getCluster()
RelOptNodegetCluster in interface RelOptNode@Pure public final @Nullable Convention getConvention(@UnknownInitialization AbstractRelNode this)
RelNodetrait set.getConvention in interface RelNodepublic RelTraitSet getTraitSet()
RelOptNodegetTraitSet in interface RelOptNodepublic @Nullable String getCorrelVariable()
RelNodegetCorrelVariable in interface RelNodepublic int getId()
RelOptNodegetId in interface RelOptNodepublic RelNode getInput(int i)
RelNodeith input relational expression.public void register(RelOptPlanner planner)
RelNodeThe planner calls this method this first time that it sees a
relational expression of this class. The derived class should call
RelOptPlanner.addRule(org.apache.calcite.plan.RelOptRule) for each rule, and
then call super.register.
public String getRelTypeName()
RelNode
org.apache.calcite.rel.ArrayRel.ArrayReader, this method returns
"ArrayReader".getRelTypeName in interface RelNodepublic boolean isValid(Litmus litmus, @Nullable RelNode.Context context)
RelNodeIf assertions are enabled, this method is typically called with
litmus = THROW, as follows:
assert rel.isValid(Litmus.THROW)
This signals that the method can throw an AssertionError if it
is not valid.
public final RelDataType getRowType()
RelNodegetRowType in interface RelOptNodegetRowType in interface RelNodeprotected RelDataType deriveRowType()
public RelDataType getExpectedInputRowType(int ordinalInParent)
RelNodeRelNode.getRowType().getExpectedInputRowType in interface RelNodeordinalInParent - input's 0-based ordinal with respect to this
parent relpublic List<RelNode> getInputs()
RelNodenull.getInputs in interface RelOptNodegetInputs in interface RelNodepublic double estimateRowCount(RelMetadataQuery mq)
RelNodeNOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use
RelMetadataQuery.getRowCount(org.apache.calcite.rel.RelNode), which gives plugins a chance to
override the rel's default ideas about row count.
estimateRowCount in interface RelNodemq - Metadata querypublic Set<CorrelationId> getVariablesSet()
RelNodeNote: only Correlate should set
variables.
getVariablesSet in interface RelNodepublic void collectVariablesUsed(Set<CorrelationId> variableSet)
RelNodecollectVariablesUsed in interface RelNodevariableSet - receives variables usedpublic boolean isEnforcer()
RelNodeisEnforcer in interface RelNodepublic void collectVariablesSet(Set<CorrelationId> variableSet)
RelNodecollectVariablesSet in interface RelNodevariableSet - receives variables known to be set bypublic void childrenAccept(RelVisitor visitor)
RelNodeRelVisitor in a
visitor pattern to
traverse the tree of relational expressions.childrenAccept in interface RelNodevisitor - Visitor that will traverse the tree of relational
expressionspublic RelNode accept(RelShuttle shuttle)
RelNodepublic RelNode accept(RexShuttle shuttle)
RelNodepublic @Nullable RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
RelNodeNOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use
RelMetadataQuery.getNonCumulativeCost(org.apache.calcite.rel.RelNode), which gives plugins a
chance to override the rel's default ideas about cost.
computeSelfCost in interface RelNodeplanner - Planner for cost calculationmq - Metadata query@Deprecated public final <M extends Metadata> M metadata(Class<M> metadataClass, RelMetadataQuery mq)
RelNodemetadata in interface RelNodeM - Type of metadata being requestedmetadataClass - Metadata interfacemq - Metadata querypublic void explain(RelWriter pw)
RelNodesuper.explain, then call the
RelWriter.input(String, RelNode)
and
RelWriter.item(String, Object)
methods for each input and attribute.public RelWriter explainTerms(RelWriter pw)
super.explainTerms, then call the
RelWriter.input(String, RelNode)
and
RelWriter.item(String, Object)
methods for each input and attribute.pw - Plan writerpublic RelNode onRegister(RelOptPlanner planner)
RelNodeonRegister in interface RelNodeplanner - Planner that plans this relational nodepublic void recomputeDigest()
RelNodeINTERNAL USE ONLY. For use by the planner.
recomputeDigest in interface RelNodeRelNode.getDigest()public void replaceInput(int ordinalInParent,
RelNode p)
RelNodeordinalInParentth input. You must
override this method if you override RelNode.getInputs().replaceInput in interface RelNodeordinalInParent - Position of the child input, 0 is the firstp - New node that should be put at position ordinalInParentpublic String toString()
@Deprecated public final String getDescription()
RelOptNodeRelOptNode.getDigest(), also includes the identity. Typically returns
"rel#{id}:{digest}".getDescription in interface RelOptNodeRelOptNode.getDigest(), also includes the identitypublic String getDigest()
RelNodeRelNode.
Each call creates a new digest string, so don't forget to cache the result if necessary.
getDigest in interface RelOptNodegetDigest in interface RelNodeRelNodeRelNode.getRelDigest()public final RelDigest getRelDigest()
RelNodeRelNode.
INTERNAL USE ONLY. For use by the planner.
getRelDigest in interface RelNodeRelNodeRelNode.getDigest()public @Nullable RelOptTable getTable()
RelNodepublic final boolean equals(@Nullable Object obj)
This method (and hashCode() is intentionally final. We do not want
sub-classes of RelNode to redefine identity. Various algorithms
(e.g. visitors, planner) can define the identity as meets their needs.
public final int hashCode()
This method (and equals(java.lang.Object) is intentionally final. We do not want
sub-classes of RelNode to redefine identity. Various algorithms
(e.g. visitors, planner) can define the identity as meets their needs.
@API(since="1.25",
status=MAINTAINED)
public boolean deepEquals(@Nullable Object obj)
By default this method collects digest attributes from
explainTerms(RelWriter), then compares each attribute pair.
This should work well for most cases. If this method is a performance
bottleneck for your project, or the default behavior can't handle
your scenario properly, you can choose to override this method and
deepHashCode(). See LogicalJoin as an example.
deepEquals in interface RelNodedeepHashCode()@API(since="1.25",
status=MAINTAINED)
public int deepHashCode()
deepHashCode in interface RelNodeRelNode.deepEquals(Object)Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.