|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface RelNode
A RelNode
is a relational expression. It is NOT an Expression
.
If this type of relational expression has some particular rules, it should
implement the public static method AbstractRelNode.register(org.eigenbase.relopt.RelOptPlanner)
.
When a relational expression comes to be implemented, the system allocates
a RelImplementor
to manage the process. Every
implementable relational expression has a RelTraitSet
describing its
physical attributes. The RelTraitSet always contains a CallingConvention
describing how the expression passes data to its consuming
relational expression, but may contain other traits, including some applied
externally. Because traits can be applied externally, implementaitons of
RelNode should never assume the size or contents of their trait set (beyond
those traits configured by the RelNode itself).
For each calling-convention, there is a corresponding sub-interface of
RelNode. For example, JavaRel
has operations to
manage the conversion to a graph of Java
calling-convention
, and it interacts with a JavaRelImplementor
.
A relational expression is only required to implement its calling-convention's interface when it is actually implemented, that is, converted into a plan/program. This means that relational expressions which cannot be implemented, such as converters, are not required to implement their convention's interface.
Every relational expression must derive from AbstractRelNode
. (Why
have the RelNode
interface, then? We need a root interface,
because an interface can only derive from an interface.)
Field Summary | |
---|---|
static AbstractRelNode[] |
emptyArray
|
Method Summary | |
---|---|
void |
childrenAccept(RelVisitor visitor)
Interacts with the RelVisitor in a visitor pattern to traverse
the tree of relational expressions. |
RelNode |
clone()
Clones this RelNode. |
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. |
RelOptCost |
computeSelfCost(RelOptPlanner planner)
Returns the cost of this plan (not including children). |
void |
explain(RelOptPlanWriter pw)
|
RexNode[] |
getChildExps()
Returns an array of this relational expression's child expressions (not including the inputs returned by getInputs() . |
RelOptCluster |
getCluster()
Returns the cluster this relational expression belongs to. |
List<RelCollation> |
getCollationList()
Returns a description of the physical ordering (or orderings) of this relational expression. |
CallingConvention |
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 this relational expression; or null if there is no variable. |
String |
getDescription()
Returns a string which describes the relational expression and, unlike 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 i th input relational expression. |
RelNode[] |
getInputs()
Returns an array of this relational expression's inputs. |
String |
getOrCreateCorrelVariable()
Returns a variable with which to reference the current row of this relational expression as a correlating variable. |
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(org.eigenbase.relopt.RelOptPlanWriter) . |
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 |
getTraits()
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 |
isAccessTo(RelOptTable table)
Returns whether this relational expression is an access to
table . |
boolean |
isDistinct()
Returns whether the same value will not come out twice. |
boolean |
isValid(boolean fail)
Returns whether this relational expression is valid. |
void |
onRegister(RelOptPlanner planner)
Receives notification that this expression is about to be registered. |
String |
recomputeDigest()
Computes the digest, assigns it, and returns it. |
void |
registerCorrelVariable(String correlVariable)
Registers a correlation variable. |
void |
replaceInput(int ordinalInParent,
RelNode p)
Replaces the ordinalInParent th input. |
void |
setCorrelVariable(String correlVariable)
Sets the name of the variable which is to be implicitly set at runtime each time a row is returned from this relational expression |
Field Detail |
---|
static final AbstractRelNode[] emptyArray
Method Detail |
---|
boolean isAccessTo(RelOptTable table)
table
.
RexNode[] getChildExps()
getInputs()
. If there are no
child expressions, returns an empty array, not null
.
RelOptCluster getCluster()
CallingConvention getConvention()
trait set
.
RelTraitSet getTraits()
void setCorrelVariable(String correlVariable)
correlVariable
- Name of correlating variableString getCorrelVariable()
boolean isDistinct()
false
, derived classes should override.
int getId()
RelNode getInput(int i)
i
th input relational expression.
i
- Ordinal of input
i
th inputString getOrCreateCorrelVariable()
RelOptQuery getQuery()
setCorrelVariable(String)
).
RelDataType getRowType()
RelDataType getExpectedInputRowType(int ordinalInParent)
getRowType()
.
ordinalInParent
- input's 0-based ordinal with respect to this
parent rel
RelNode[] getInputs()
null
.
double getRows()
NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use
RelMetadataQuery.getRowCount(org.eigenbase.rel.RelNode)
, which gives plugins a chance to
override the rel's default ideas about row count.
Set<String> getVariablesStopped()
By default, returns the empty set. Derived classes may override this method.
void collectVariablesUsed(Set<String> variableSet)
variableSet
- receives variables usedvoid collectVariablesSet(Set<String> variableSet)
variableSet
- receives variables known to be set byvoid childrenAccept(RelVisitor visitor)
RelVisitor
in a visitor pattern
to traverse
the tree of relational expressions.
RelOptCost computeSelfCost(RelOptPlanner planner)
NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use
RelMetadataQuery.getNonCumulativeCost(org.eigenbase.rel.RelNode)
, which gives plugins a
chance to override the rel's default ideas about cost.
void explain(RelOptPlanWriter pw)
void onRegister(RelOptPlanner planner)
String recomputeDigest()
void registerCorrelVariable(String correlVariable)
getVariablesStopped()
void replaceInput(int ordinalInParent, RelNode p)
ordinalInParent
th input. You must
override this method if you override getInputs()
.
RelOptTable getTable()
String getRelTypeName()
explain(org.eigenbase.relopt.RelOptPlanWriter)
. For example, for a
org.eigenbase.rel.ArrayRel.ArrayReader
, this method returns
"ArrayReader".
boolean isValid(boolean fail)
If 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.
fail
- Whether to fail if invalid
AssertionError
- if this relational expression is invalid and
fail=true and assertions are enabledList<RelCollation> getCollationList()
String getDigest()
The 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}".
String getDescription()
getDigest()
, also includes the identity. Typically returns
"rel#{id}:{digest}".
RelNode clone()
Traits of the RelNode must be explicitly cloned, using AbstractRelNode.inheritTraitsFrom(AbstractRelNode)
, as the RelNode may
have traits of which it has no knowledge. Example implementation:
public MyRelNode clone() { MyRelNode clone = new MyRelNode(...); clone.inheritTraitsFrom(this); return clone; }N.B.: This method must be overridden whenever an existing, concrete RelNode is extended. Otherwise, calling clone() will produce a differently typed RelNode, resulting in invalid or incorrect query plans.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |