| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.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 ith 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 ordinalInParentth 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().
descprivate 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()
RelNodeTraits 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 RelNodeclone in class Objectpublic boolean isAccessTo(RelOptTable table)
RelNode
 table.
isAccessTo in interface RelNodepublic RexNode[] getChildExps()
RelNodeRelNode.getInputs(). If there are no
 child expressions, returns an empty array, not null.
getChildExps in interface RelNodepublic RelOptCluster getCluster()
RelNode
getCluster in interface RelNodepublic final CallingConvention getConvention()
RelNodetrait set.
getConvention in interface RelNodepublic RelTraitSet getTraits()
RelNode
getTraits in interface RelNodepublic 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 RelNodecorrelVariable - Name of correlating variablepublic String getCorrelVariable()
RelNode
getCorrelVariable in interface RelNodepublic boolean isDistinct()
RelNodefalse, derived classes should override.
isDistinct in interface RelNodepublic int getId()
RelNode
getId in interface RelNodepublic RelNode getInput(int i)
RelNodeith input relational expression.
getInput in interface RelNodei - Ordinal of input
ith inputpublic String getOrCreateCorrelVariable()
RelNode
getOrCreateCorrelVariable in interface RelNodepublic RelOptQuery getQuery()
RelNodeRelNode.setCorrelVariable(String)).
getQuery in interface RelNodepublic 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()
RelNodeRelNode.explain(org.eigenbase.relopt.RelOptPlanWriter). For example, for a 
 org.eigenbase.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.
isValid in interface RelNodefail - Whether to fail if invalid
public List<RelCollation> getCollationList()
RelNode
getCollationList in interface RelNodepublic final RelDataType getRowType()
RelNode
getRowType 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 rel
public RelNode[] getInputs()
RelNodenull.
getInputs in interface RelNodepublic double getRows()
RelNodeNOTE 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 RelNodepublic Set<String> getVariablesStopped()
RelNodeBy default, returns the empty set. Derived classes may override this method.
getVariablesStopped in interface RelNodepublic void collectVariablesUsed(Set<String> variableSet)
RelNode
collectVariablesUsed in interface RelNodevariableSet - receives variables usedpublic void collectVariablesSet(Set<String> variableSet)
RelNode
collectVariablesSet 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 RelNodepublic RelOptCost computeSelfCost(RelOptPlanner planner)
RelNodeNOTE 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 RelNodepublic void explain(RelOptPlanWriter pw)
explain in interface RelNodepublic void onRegister(RelOptPlanner planner)
RelNode
onRegister in interface RelNodepublic String recomputeDigest()
RelNode
recomputeDigest in interface RelNodepublic void registerCorrelVariable(String correlVariable)
RelNode
registerCorrelVariable in interface RelNodeRelNode.getVariablesStopped()
public void replaceInput(int ordinalInParent,
                         RelNode p)
RelNodeordinalInParentth input. You must
 override this method if you override RelNode.getInputs().
replaceInput in interface RelNodepublic String toString()
toString in class Objectpublic final String getDescription()
RelNodeRelNode.getDigest(), also includes the identity. Typically returns
 "rel#{id}:{digest}".
getDescription in interface RelNodepublic final String getDigest()
RelNodeThe 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 RelNodepublic RelOptTable getTable()
RelNode
getTable in interface RelNodeprotected String computeDigest()
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||