|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.rel.AbstractRelNode
public abstract class AbstractRelNode
Base class for every relational expression (RelNode
).
Field Summary | |
---|---|
private RelOptCluster |
cluster
|
private String |
correlVariable
The variable by which to refer to rows from this relational expression, as correlating expressions; null if this expression is not correlated on. |
private String |
desc
Description, consists of id plus digest. |
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 |
(package private) static int |
nextId
generator for id values |
protected RelDataType |
rowType
Cached type of this relational expression. |
private static Logger |
tracer
|
protected RelTraitSet |
traits
The RelTraitSet that describes the traits of this RelNode. |
Fields inherited from interface org.eigenbase.rel.RelNode |
---|
emptyArray |
Constructor Summary | |
---|---|
AbstractRelNode(RelOptCluster cluster,
RelTraitSet traits)
Creates a AbstractRelNode . |
Method Summary | ||
---|---|---|
void |
childrenAccept(RelVisitor visitor)
Interacts with the RelVisitor in a visitor pattern to traverse
the tree of relational expressions. |
|
abstract RelNode |
clone()
Clones this RelNode. |
|
RelTraitSet |
cloneTraits()
Returns a clone of this RelNode's traits. |
|
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). |
|
protected RelDataType |
deriveRowType()
|
|
void |
explain(RelOptPlanWriter pw)
|
|
RexNode[] |
getChildExps()
Returns an array of this relational expression's child expressions (not including the inputs returned by RelNode.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 RelNode.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 RelNode.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. |
|
|
inheritTraitsFrom(T rel)
Sets this relational expression's traits to the same as another 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. |
|
static void |
register(RelOptPlanner planner)
Registers any special rules specific to this kind of relational expression. |
|
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 |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
static int nextId
id
values
private static final Logger tracer
private String desc
protected RelDataType rowType
protected String digest
computeDigest()
, assigned by onRegister(org.eigenbase.relopt.RelOptPlanner)
, returned by getDigest()
.
desc
private RelOptCluster cluster
protected int id
private String correlVariable
protected RelTraitSet traits
Constructor Detail |
---|
public AbstractRelNode(RelOptCluster cluster, RelTraitSet traits)
AbstractRelNode
.
Method Detail |
---|
public abstract RelNode clone()
RelNode
Traits of the RelNode must be explicitly cloned, using 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.
clone
in interface RelNode
clone
in class Object
public boolean isAccessTo(RelOptTable table)
RelNode
table
.
isAccessTo
in interface RelNode
public RexNode[] getChildExps()
RelNode
RelNode.getInputs()
. If there are no
child expressions, returns an empty array, not null
.
getChildExps
in interface RelNode
public RelOptCluster getCluster()
RelNode
getCluster
in interface RelNode
public final CallingConvention getConvention()
RelNode
trait set
.
getConvention
in interface RelNode
public RelTraitSet getTraits()
RelNode
getTraits
in interface RelNode
public RelTraitSet cloneTraits()
clone()
.
public <T extends AbstractRelNode> T inheritTraitsFrom(T rel)
The typical use of this method is in the implementation of a clone()
method:
class MyRel { public MyRel clone() { return new MyRel(
getCluster(), getChild().clone(), fieldX.clone(), fieldY.clone())
.inheritTraitsFrom(this); } }
To enable calls to be chained in this way, this method returns
this
as a convenience.
rel
- Relational expression whose traits to copy
public void setCorrelVariable(String correlVariable)
RelNode
setCorrelVariable
in interface RelNode
correlVariable
- Name of correlating variablepublic String getCorrelVariable()
RelNode
getCorrelVariable
in interface RelNode
public boolean isDistinct()
RelNode
false
, derived classes should override.
isDistinct
in interface RelNode
public int getId()
RelNode
getId
in interface RelNode
public RelNode getInput(int i)
RelNode
i
th input relational expression.
getInput
in interface RelNode
i
- Ordinal of input
i
th inputpublic String getOrCreateCorrelVariable()
RelNode
getOrCreateCorrelVariable
in interface RelNode
public RelOptQuery getQuery()
RelNode
RelNode.setCorrelVariable(String)
).
getQuery
in interface RelNode
public static void register(RelOptPlanner planner)
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.eigenbase.relopt.RelOptRule)
for each rule, and then call register(org.eigenbase.relopt.RelOptPlanner)
on
its base class.
public final String getRelTypeName()
RelNode
RelNode.explain(org.eigenbase.relopt.RelOptPlanWriter)
. For example, for a
org.eigenbase.rel.ArrayRel.ArrayReader
, this method returns
"ArrayReader".
getRelTypeName
in interface RelNode
public boolean isValid(boolean fail)
RelNode
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.
isValid
in interface RelNode
fail
- Whether to fail if invalid
public List<RelCollation> getCollationList()
RelNode
getCollationList
in interface RelNode
public final RelDataType getRowType()
RelNode
getRowType
in interface RelNode
protected RelDataType deriveRowType()
public RelDataType getExpectedInputRowType(int ordinalInParent)
RelNode
RelNode.getRowType()
.
getExpectedInputRowType
in interface RelNode
ordinalInParent
- input's 0-based ordinal with respect to this
parent rel
public RelNode[] getInputs()
RelNode
null
.
getInputs
in interface RelNode
public double getRows()
RelNode
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.
getRows
in interface RelNode
public Set<String> getVariablesStopped()
RelNode
By default, returns the empty set. Derived classes may override this method.
getVariablesStopped
in interface RelNode
public void collectVariablesUsed(Set<String> variableSet)
RelNode
collectVariablesUsed
in interface RelNode
variableSet
- receives variables usedpublic void collectVariablesSet(Set<String> variableSet)
RelNode
collectVariablesSet
in interface RelNode
variableSet
- receives variables known to be set bypublic void childrenAccept(RelVisitor visitor)
RelNode
RelVisitor
in a visitor pattern
to traverse
the tree of relational expressions.
childrenAccept
in interface RelNode
public RelOptCost computeSelfCost(RelOptPlanner planner)
RelNode
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.
computeSelfCost
in interface RelNode
public void explain(RelOptPlanWriter pw)
explain
in interface RelNode
public void onRegister(RelOptPlanner planner)
RelNode
onRegister
in interface RelNode
public String recomputeDigest()
RelNode
recomputeDigest
in interface RelNode
public void registerCorrelVariable(String correlVariable)
RelNode
registerCorrelVariable
in interface RelNode
RelNode.getVariablesStopped()
public void replaceInput(int ordinalInParent, RelNode p)
RelNode
ordinalInParent
th input. You must
override this method if you override RelNode.getInputs()
.
replaceInput
in interface RelNode
public String toString()
toString
in class Object
public final String getDescription()
RelNode
RelNode.getDigest()
, also includes the identity. Typically returns
"rel#{id}:{digest}".
getDescription
in interface RelNode
public final String getDigest()
RelNode
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}".
getDigest
in interface RelNode
public RelOptTable getTable()
RelNode
getTable
in interface RelNode
protected String computeDigest()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |