Class AbstractRelNode
- All Implemented Interfaces:
Cloneable,RelOptNode,RelNode
- Direct Known Subclasses:
BiRel,Combine,DruidQuery,HepRelVertex,HyperGraph,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
FieldsModifier and TypeFieldDescriptionprotected final RelDigestThe digest that uniquely identifies the node.protected final intUnique id of this object, for debugging.protected @MonotonicNonNull RelDataTypeCached type of this relational expression.protected final RelTraitSetRelTraitSet that describes the traits of this RelNode. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRelNode(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.voidchildrenAccept(RelVisitor visitor) Interacts with theRelVisitorin avisitor patternto traverse the tree of relational expressions.voidcollectVariablesSet(Set<CorrelationId> variableSet) Collects variables set by this expression.voidcollectVariablesUsed(Set<CorrelationId> variableSet) Collects variables known to be used by this expression or its descendants.@Nullable RelOptCostcomputeSelfCost(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.booleandeepEquals(@Nullable Object obj) Equality check for RelNode digest.intCompute hash code for RelNode digest.protected RelDataTypefinal booleandoubleReturns an estimate of the number of rows this relational expression will return.voidDescribes the inputs and attributes of this relational expression.Describes the inputs and attributes of this relational expression.final RelOptClusterReturns the cluster this relational expression belongs to.final @Nullable ConventionReturn the CallingConvention trait from this RelNode'strait set.@Nullable StringReturns 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 StringDeprecated.Returns a digest string of thisRelNode.getExpectedInputRowType(int ordinalInParent) Returns the type of the rows expected for an input.intgetId()Returns the ID of this relational expression, unique among all relational expressions created since the server was started.getInput(int i) Returns theith input relational expression.Returns an array of this relational expression's inputs.final RelDigestReturns a digest of thisRelNode.Returns the name of this relational expression's class, sans package name, for use in explain.final RelDataTypeReturns the type of the rows returned by this relational expression.@Nullable RelOptTablegetTable()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 inthashCode()booleanIndicates whether it is an enforcer operator, e.g.booleanisValid(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.voidRecomputes the digest.voidregister(RelOptPlanner planner) Registers any special rules specific to this kind of relational expression.voidreplaceInput(int ordinalInParent, RelNode p) Replaces theordinalInParentth input.protected static <T> TtoString()Description; consists of id plus digest.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:RelNodeCreates 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:RelOptNodeReturns the cluster this relational expression belongs to.- Specified by:
getClusterin interfaceRelOptNode- Returns:
- cluster
-
getConvention
Description copied from interface:RelNodeReturn the CallingConvention trait from this RelNode'strait set.- Specified by:
getConventionin interfaceRelNode- Returns:
- this RelNode's CallingConvention
-
getTraitSet
Description copied from interface:RelOptNodeRetrieves 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:
getTraitSetin interfaceRelOptNode- Returns:
- this RelNode's trait set
-
getCorrelVariable
Description copied from interface:RelNodeReturns 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:
getCorrelVariablein interfaceRelNode- Returns:
- Name of correlating variable, or null
-
getId
public int getId()Description copied from interface:RelOptNodeReturns the ID of this relational expression, unique among all relational expressions created since the server was started.- Specified by:
getIdin interfaceRelOptNode- Returns:
- Unique ID
-
getInput
Description copied from interface:RelNodeReturns theith input relational expression. -
register
Description copied from interface:RelNodeRegisters 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:RelNodeReturns 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:
getRelTypeNamein interfaceRelNode- Returns:
- Name of this relational expression's class, sans package name, for use in explain
-
isValid
Description copied from interface:RelNodeReturns 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
AssertionErrorif it is not valid. -
getRowType
Description copied from interface:RelNodeReturns the type of the rows returned by this relational expression.- Specified by:
getRowTypein interfaceRelNode- Specified by:
getRowTypein interfaceRelOptNode
-
deriveRowType
-
getExpectedInputRowType
Description copied from interface:RelNodeReturns the type of the rows expected for an input. Defaults toRelNode.getRowType().- Specified by:
getExpectedInputRowTypein interfaceRelNode- Parameters:
ordinalInParent- input's 0-based ordinal with respect to this parent rel- Returns:
- expected row type
-
getInputs
Description copied from interface:RelNodeReturns an array of this relational expression's inputs. If there are no inputs, returns an empty list, notnull.- Specified by:
getInputsin interfaceRelNode- Specified by:
getInputsin interfaceRelOptNode- Returns:
- Array of this relational expression's inputs
-
estimateRowCount
Description copied from interface:RelNodeReturns 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:
estimateRowCountin interfaceRelNode- Parameters:
mq- Metadata query- Returns:
- Estimate of the number of rows this relational expression will return
-
getVariablesSet
Description copied from interface:RelNodeReturns the variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.- Specified by:
getVariablesSetin interfaceRelNode- Returns:
- Names of variables which are set in this relational expression
-
collectVariablesUsed
Description copied from interface:RelNodeCollects 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:
collectVariablesUsedin interfaceRelNode- Parameters:
variableSet- receives variables used
-
isEnforcer
public boolean isEnforcer()Description copied from interface:RelNodeIndicates 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:
isEnforcerin interfaceRelNode- Returns:
- Whether it is an enforcer operator
-
collectVariablesSet
Description copied from interface:RelNodeCollects variables set by this expression. TODO: is this required?- Specified by:
collectVariablesSetin interfaceRelNode- Parameters:
variableSet- receives variables known to be set by
-
childrenAccept
Description copied from interface:RelNodeInteracts with theRelVisitorin avisitor patternto traverse the tree of relational expressions.- Specified by:
childrenAcceptin interfaceRelNode- Parameters:
visitor- Visitor that will traverse the tree of relational expressions
-
accept
Description copied from interface:RelNodeAccepts a visit from a shuttle. -
accept
Description copied from interface:RelNodeAccepts 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:RelNodeReturns 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:
computeSelfCostin 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:RelNodeReturns a metadata interface.- Specified by:
metadatain 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:RelNodeDescribes 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:RelNodeReceives notification that this expression is about to be registered. The implementation of this method must at least register all child expressions.- Specified by:
onRegisterin 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:RelNodeRecomputes the digest.INTERNAL USE ONLY. For use by the planner.
- Specified by:
recomputeDigestin interfaceRelNode- See Also:
-
replaceInput
Description copied from interface:RelNodeReplaces theordinalInParentth input. You must override this method if you overrideRelNode.getInputs().- Specified by:
replaceInputin 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:RelOptNodeReturns a string which describes the relational expression and, unlikeRelOptNode.getDigest(), also includes the identity. Typically returns "rel#{id}:{digest}".- Specified by:
getDescriptionin interfaceRelOptNode- Returns:
- String which describes the relational expression and, unlike
RelOptNode.getDigest(), also includes the identity
-
getDigest
Description copied from interface:RelNodeReturns a digest string of thisRelNode.Each call creates a new digest string, so don't forget to cache the result if necessary.
- Specified by:
getDigestin interfaceRelNode- Specified by:
getDigestin interfaceRelOptNode- Returns:
- Digest string of this
RelNode - See Also:
-
getRelDigest
Description copied from interface:RelNodeReturns a digest of thisRelNode.INTERNAL USE ONLY. For use by the planner.
- Specified by:
getRelDigestin interfaceRelNode- Returns:
- Digest of this
RelNode - See Also:
-
getTable
Description copied from interface:RelNodeIf 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 ofRelNodeto 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 ofRelNodeto 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(). SeeLogicalJoinas an example.- Specified by:
deepEqualsin 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:
deepHashCodein interfaceRelNode- See Also:
-