Class AbstractRelNode
- All Implemented Interfaces:
Cloneable
,RelOptNode
,RelNode
- Direct Known Subclasses:
BiRel
,DruidQuery
,HepRelVertex
,MultiJoin
,RelSubset
,SetOp
,SingleRel
,TableFunctionScan
,TableScan
,Values
RelNode
).-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context
-
Field Summary
Modifier and TypeFieldDescriptionprotected final RelDigest
The digest that uniquely identifies the node.protected final int
Unique id of this object, for debugging.protected @MonotonicNonNull RelDataType
Cached type of this relational expression.protected final RelTraitSet
RelTraitSet that describes the traits of this RelNode. -
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractRelNode
(RelOptCluster cluster, RelTraitSet traitSet) Creates anAbstractRelNode
. -
Method Summary
Modifier and TypeMethodDescriptionaccept
(RelShuttle shuttle) Accepts a visit from a shuttle.accept
(RexShuttle shuttle) Accepts a visit from a shuttle.void
childrenAccept
(RelVisitor visitor) Interacts with theRelVisitor
in avisitor 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).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
Compute hash code for RelNode digest.protected RelDataType
final boolean
double
Returns an estimate of the number of rows this relational expression will return.void
Describes the inputs and attributes of this relational expression.Describes the inputs and attributes of this relational expression.final RelOptCluster
Returns the cluster this relational expression belongs to.final @Nullable Convention
Return the CallingConvention trait from this RelNode'strait set
.@Nullable String
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.final String
Deprecated.Returns a digest string of thisRelNode
.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.getInput
(int i) Returns thei
th input relational expression.Returns an array of this relational expression's inputs.final RelDigest
Returns a digest of thisRelNode
.Returns the name of this relational expression's class, sans package name, for use in explain.final RelDataType
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.Retrieves this RelNode's traits.Returns the variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.final int
hashCode()
boolean
Indicates whether it is an enforcer operator, e.g.boolean
isValid
(Litmus litmus, @Nullable RelNode.Context context) Returns whether this relational expression is valid.final <@Nullable M extends @Nullable Metadata>
Mmetadata
(Class<@Nullable M> metadataClass, RelMetadataQuery mq) Deprecated.onRegister
(RelOptPlanner planner) Receives notification that this expression is about to be registered.void
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 theordinalInParent
th input.protected static <T> T
toString()
Description; consists of id plus digest.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.calcite.rel.RelNode
explain, fieldIsNullable, stripped
-
Field Details
-
rowType
Cached type of this relational expression. -
digest
The digest that uniquely identifies the node. -
id
protected final int idUnique id of this object, for debugging. -
traitSet
RelTraitSet that describes the traits of this RelNode.
-
-
Constructor Details
-
AbstractRelNode
Creates anAbstractRelNode
.
-
-
Method Details
-
copy
Description copied from interface:RelNode
Creates a copy of this relational expression, perhaps changing traits and inputs.Sub-classes with other important attributes are encouraged to create variants of this method with more parameters.
-
sole
-
getCluster
Description copied from interface:RelOptNode
Returns the cluster this relational expression belongs to.- Specified by:
getCluster
in interfaceRelOptNode
- Returns:
- cluster
-
getConvention
Description copied from interface:RelNode
Return the CallingConvention trait from this RelNode'strait set
.- Specified by:
getConvention
in interfaceRelNode
- Returns:
- this RelNode's CallingConvention
-
getTraitSet
Description copied from interface:RelOptNode
Retrieves this RelNode's traits. Note that although the RelTraitSet returned is modifiable, it must not be modified during optimization. It is legal to modify the traits of a RelNode before or after optimization, although doing so could render a tree of RelNodes unimplementable. If a RelNode's traits need to be modified during optimization, clone the RelNode and change the clone's traits.- Specified by:
getTraitSet
in interfaceRelOptNode
- Returns:
- this RelNode's trait set
-
getCorrelVariable
Description copied from interface:RelNode
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.- Specified by:
getCorrelVariable
in interfaceRelNode
- Returns:
- Name of correlating variable, or null
-
getId
public int getId()Description copied from interface:RelOptNode
Returns the ID of this relational expression, unique among all relational expressions created since the server was started.- Specified by:
getId
in interfaceRelOptNode
- Returns:
- Unique ID
-
getInput
Description copied from interface:RelNode
Returns thei
th input relational expression. -
register
Description copied from interface:RelNode
Registers any special rules specific to this kind of relational expression.The 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 callsuper.register
. -
getRelTypeName
Description copied from interface:RelNode
Returns the name of this relational expression's class, sans package name, for use in explain. For example, for aorg.apache.calcite.rel.ArrayRel.ArrayReader
, this method returns "ArrayReader".- Specified by:
getRelTypeName
in interfaceRelNode
- Returns:
- Name of this relational expression's class, sans package name, for use in explain
-
isValid
Description copied from interface:RelNode
Returns whether this relational expression is valid.If 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. -
getRowType
Description copied from interface:RelNode
Returns the type of the rows returned by this relational expression.- Specified by:
getRowType
in interfaceRelNode
- Specified by:
getRowType
in interfaceRelOptNode
-
deriveRowType
-
getExpectedInputRowType
Description copied from interface:RelNode
Returns the type of the rows expected for an input. Defaults toRelNode.getRowType()
.- Specified by:
getExpectedInputRowType
in interfaceRelNode
- Parameters:
ordinalInParent
- input's 0-based ordinal with respect to this parent rel- Returns:
- expected row type
-
getInputs
Description copied from interface:RelNode
Returns an array of this relational expression's inputs. If there are no inputs, returns an empty list, notnull
.- Specified by:
getInputs
in interfaceRelNode
- Specified by:
getInputs
in interfaceRelOptNode
- Returns:
- Array of this relational expression's inputs
-
estimateRowCount
Description copied from interface:RelNode
Returns an estimate of the number of rows this relational expression will return.NOTE 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.- Specified by:
estimateRowCount
in interfaceRelNode
- Parameters:
mq
- Metadata query- Returns:
- Estimate of the number of rows this relational expression will return
-
getVariablesSet
Description copied from interface:RelNode
Returns the variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.- Specified by:
getVariablesSet
in interfaceRelNode
- Returns:
- Names of variables which are set in this relational expression
-
collectVariablesUsed
Description copied from interface:RelNode
Collects variables known to be used by this expression or its descendants. By default, no such information is available and must be derived by analyzing sub-expressions, but some optimizer implementations may insert special expressions which remember such information.- Specified by:
collectVariablesUsed
in interfaceRelNode
- Parameters:
variableSet
- receives variables used
-
isEnforcer
public boolean isEnforcer()Description copied from interface:RelNode
Indicates whether it is an enforcer operator, e.g. PhysicalSort, PhysicalHashDistribute, etc. As an enforcer, the operator must be created only when required traitSet is not satisfied by its input.- Specified by:
isEnforcer
in interfaceRelNode
- Returns:
- Whether it is an enforcer operator
-
collectVariablesSet
Description copied from interface:RelNode
Collects variables set by this expression. TODO: is this required?- Specified by:
collectVariablesSet
in interfaceRelNode
- Parameters:
variableSet
- receives variables known to be set by
-
childrenAccept
Description copied from interface:RelNode
Interacts with theRelVisitor
in avisitor pattern
to traverse the tree of relational expressions.- Specified by:
childrenAccept
in interfaceRelNode
- Parameters:
visitor
- Visitor that will traverse the tree of relational expressions
-
accept
Description copied from interface:RelNode
Accepts a visit from a shuttle. -
accept
Description copied from interface:RelNode
Accepts a visit from a shuttle. If the shuttle updates expression, then a copy of the relation should be created. This new relation might have a different row-type. -
computeSelfCost
Description copied from interface:RelNode
Returns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.NOTE 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.- Specified by:
computeSelfCost
in interfaceRelNode
- Parameters:
planner
- Planner for cost calculationmq
- Metadata query- Returns:
- Cost of this plan (not including children)
-
metadata
@Deprecated public final <@Nullable M extends @Nullable Metadata> M metadata(Class<@Nullable M> metadataClass, RelMetadataQuery mq) Deprecated.Description copied from interface:RelNode
Returns a metadata interface.- Specified by:
metadata
in interfaceRelNode
- Type Parameters:
M
- Type of metadata being requested- Parameters:
metadataClass
- Metadata interfacemq
- Metadata query- Returns:
- Metadata object that supplies the desired metadata (never null, although if the information is not present the metadata object may return null from all methods)
-
explain
Description copied from interface:RelNode
Describes the inputs and attributes of this relational expression. Each node should callsuper.explain
, then call theRelWriter.input(String, RelNode)
andRelWriter.item(String, Object)
methods for each input and attribute. -
explainTerms
Describes the inputs and attributes of this relational expression. Each node should callsuper.explainTerms
, then call theRelWriter.input(String, RelNode)
andRelWriter.item(String, Object)
methods for each input and attribute.- Parameters:
pw
- Plan writer- Returns:
- Plan writer for fluent-explain pattern
-
onRegister
Description copied from interface:RelNode
Receives notification that this expression is about to be registered. The implementation of this method must at least register all child expressions.- Specified by:
onRegister
in interfaceRelNode
- Parameters:
planner
- Planner that plans this relational node- Returns:
- Relational expression that should be used by the planner
-
recomputeDigest
public void recomputeDigest()Description copied from interface:RelNode
Recomputes the digest.INTERNAL USE ONLY. For use by the planner.
- Specified by:
recomputeDigest
in interfaceRelNode
- See Also:
-
replaceInput
Description copied from interface:RelNode
Replaces theordinalInParent
th input. You must override this method if you overrideRelNode.getInputs()
.- Specified by:
replaceInput
in interfaceRelNode
- Parameters:
ordinalInParent
- Position of the child input, 0 is the firstp
- New node that should be put at positionordinalInParent
-
toString
Description; consists of id plus digest. -
getDescription
Deprecated.Description copied from interface:RelOptNode
Returns a string which describes the relational expression and, unlikeRelOptNode.getDigest()
, also includes the identity. Typically returns "rel#{id}:{digest}".- Specified by:
getDescription
in interfaceRelOptNode
- Returns:
- String which describes the relational expression and, unlike
RelOptNode.getDigest()
, also includes the identity
-
getDigest
Description copied from interface:RelNode
Returns a digest string of thisRelNode
.Each call creates a new digest string, so don't forget to cache the result if necessary.
- Specified by:
getDigest
in interfaceRelNode
- Specified by:
getDigest
in interfaceRelOptNode
- Returns:
- Digest string of this
RelNode
- See Also:
-
getRelDigest
Description copied from interface:RelNode
Returns a digest of thisRelNode
.INTERNAL USE ONLY. For use by the planner.
- Specified by:
getRelDigest
in interfaceRelNode
- Returns:
- Digest of this
RelNode
- See Also:
-
getTable
Description copied from interface:RelNode
If this relational expression represents an access to a table, returns that table, otherwise returns null. -
equals
This method (and
hashCode()
is intentionally final. We do not want sub-classes ofRelNode
to redefine identity. Various algorithms (e.g. visitors, planner) can define the identity as meets their needs. -
hashCode
public final int hashCode()This method (and
equals(java.lang.Object)
is intentionally final. We do not want sub-classes ofRelNode
to redefine identity. Various algorithms (e.g. visitors, planner) can define the identity as meets their needs. -
deepEquals
Equality check for RelNode digest.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 anddeepHashCode()
. SeeLogicalJoin
as an example.- Specified by:
deepEquals
in interfaceRelNode
- Returns:
- Whether the 2 RelNodes are equivalent or have the same digest.
- See Also:
-
deepHashCode
@API(since="1.25", status=MAINTAINED) public int deepHashCode()Compute hash code for RelNode digest.- Specified by:
deepHashCode
in interfaceRelNode
- See Also:
-