public abstract class AbstractRelNode extends Object implements RelNode
RelNode).| Modifier and Type | Field and Description |
|---|---|
protected String |
digest
A short description of this relational expression's type, inputs, and
other properties.
|
protected int |
id
unique id of this object -- for debugging
|
protected RelDataType |
rowType
Cached type of this relational expression.
|
protected RelTraitSet |
traitSet
The RelTraitSet that describes the traits of this RelNode.
|
| Constructor and Description |
|---|
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<String> variableSet)
Collects variables set by this expression.
|
void |
collectVariablesUsed(Set<String> variableSet)
Collects variables known to be used by this expression or its
descendants.
|
protected String |
computeDigest()
Computes the digest.
|
RelOptCost |
computeSelfCost(RelOptPlanner planner)
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.
|
protected RelDataType |
deriveRowType() |
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.
|
List<RexNode> |
getChildExps()
Returns a list of this relational expression's child expressions.
|
RelOptCluster |
getCluster()
Returns the cluster this relational expression belongs to.
|
List<RelCollation> |
getCollationList()
Deprecated.
|
Convention |
getConvention()
Return the CallingConvention trait from this RelNode's
trait set. |
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()
Returns a string which describes the relational expression and, unlike
RelOptNode.getDigest(), also includes the identity. |
String |
getDigest()
Returns a string which concisely describes the definition of this
relational expression.
|
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.
|
RelOptQuery |
getQuery()
Returns the sub-query this relational expression belongs to.
|
String |
getRelTypeName()
Returns the name of this relational expression's class, sans package
name, for use in explain.
|
double |
getRows()
Returns an estimate of the number of rows this relational expression will
return.
|
RelDataType |
getRowType()
Returns the type of the rows returned by this relational expression.
|
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<String> |
getVariablesStopped()
Returns the names of variables which are set in this relational
expression but also used and therefore not available to parents of this
relational expression.
|
boolean |
isDistinct()
Returns whether the same value will not come out twice.
|
boolean |
isKey(ImmutableBitSet columns)
Returns whether the result of this relational expression is uniquely
identified by this columns with the given ordinals.
|
boolean |
isValid(boolean fail)
Returns whether this relational expression is valid.
|
<M extends Metadata> |
metadata(Class<M> metadataClass)
Returns a metadata interface.
|
RelNode |
onRegister(RelOptPlanner planner)
Receives notification that this expression is about to be registered.
|
String |
recomputeDigest()
Computes the digest, assigns it, and returns it.
|
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() |
protected RelDataType rowType
protected String digest
computeDigest(), assigned by onRegister(org.apache.calcite.plan.RelOptPlanner), returned by
getDigest().descprotected int id
protected RelTraitSet traitSet
public 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 List<RexNode> getChildExps()
RelNodeRelNode.getInputs().
The caller should treat the list as unmodifiable; typical
implementations will return an immutable list. If there are no
child expressions, returns an empty list, not null.
getChildExps in interface RelNodeRelNode.accept(org.apache.calcite.rex.RexShuttle)public final RelOptCluster getCluster()
RelOptNodegetCluster in interface RelOptNodepublic final Convention getConvention()
RelNodetrait set.getConvention in interface RelNodepublic RelTraitSet getTraitSet()
RelOptNodegetTraitSet in interface RelOptNodepublic String getCorrelVariable()
RelNodegetCorrelVariable in interface RelNodepublic boolean isDistinct()
RelNodefalse, derived classes should override.isDistinct in interface RelNodepublic boolean isKey(ImmutableBitSet columns)
RelNodeFor example, if this relational expression is a LogicalTableScan to T(A, B, C, D) whose key is (A, B), then isKey([0, 1]) yields true, and isKey([0]) and isKey([0, 2]) yields false.
public int getId()
RelOptNodegetId in interface RelOptNodepublic RelNode getInput(int i)
RelNodeith input relational expression.public final RelOptQuery getQuery()
RelNodepublic 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 final String getRelTypeName()
RelNode
org.apache.calcite.rel.ArrayRel.ArrayReader, this method returns
"ArrayReader".getRelTypeName in interface RelNodepublic boolean isValid(boolean fail)
RelNodeIf assertions are enabled, this method is typically called with
fail = true, as follows:
This signals that the method can throw anassert rel.isValid(true)
AssertionError if it is
not valid.@Deprecated public List<RelCollation> getCollationList()
RelMetadataQuery.collations(RelNode)RelNodegetCollationList in interface RelNodepublic 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 getRows()
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.
public Set<String> getVariablesStopped()
RelNodeNote: only Correlate should set
variables
getVariablesStopped in interface RelNodepublic void collectVariablesUsed(Set<String> variableSet)
RelNodecollectVariablesUsed in interface RelNodevariableSet - receives variables usedpublic void collectVariablesSet(Set<String> 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 RelOptCost computeSelfCost(RelOptPlanner planner)
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 calculationpublic final <M extends Metadata> M metadata(Class<M> metadataClass)
RelNodemetadata in interface RelNodeM - Type of metadata being requestedmetadataClass - Metadata interfacepublic void explain(RelWriter pw)
RelNodesuper.explain, then call the
RelWriterImpl.input(String, RelNode)
and
RelWriterImpl.item(String, Object)
methods for each input and attribute.public RelWriter explainTerms(RelWriter pw)
super.explainTerms, then call the
RelWriterImpl.input(String, RelNode)
and
RelWriterImpl.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 String recomputeDigest()
RelNoderecomputeDigest in interface RelNodepublic 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 final String getDescription()
RelOptNodeRelOptNode.getDigest(), also includes the identity. Typically returns
"rel#{id}:{digest}".getDescription in interface RelOptNodeRelOptNode.getDigest(), also includes the identitypublic final String getDigest()
RelOptNodeThe digest does not contain the relational expression's identity -- that would prevent similar relational expressions from ever comparing equal -- but does include the identity of children (on the assumption that children have already been normalized).
If you want a descriptive string which contains the identity, call
Object.toString(), which always returns "rel#{id}:{digest}".
getDigest in interface RelOptNodeRelNodepublic RelOptTable getTable()
RelNodeprotected String computeDigest()
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.