org.eigenbase.relopt.volcano
Class RelSubset

java.lang.Object
  extended by org.eigenbase.rel.AbstractRelNode
      extended by org.eigenbase.relopt.volcano.RelSubset
All Implemented Interfaces:
Cloneable, RelNode

public class RelSubset
extends AbstractRelNode

A RelSubset is set of expressions in a set which have the same calling convention. An expression may be in more than one sub-set of a set; the same expression is used.

Since:
16 December, 2001
Version:
$Id: //open/dev/farrago/src/org/eigenbase/relopt/volcano/RelSubset.java#3 $
Author:
jhyde

Nested Class Summary
(package private)  class RelSubset.CheapestPlanReplacer
          Visitor which walks over a tree of RelSets, replacing each node with the cheapest implementation of the expression.
 
Field Summary
(package private)  boolean active
          whether findBestPlan is being called
(package private)  RelNode best
          best known plan
(package private)  RelOptCost bestCost
          cost of best known plan (it may have improved since)
(package private)  boolean boosted
          Flag indicating whether this RelSubset's importance was artificially boosted.
(package private)  List<RelNode> parents
          List of the relational expressions for which this subset is an input.
(package private)  List<RelNode> rels
          The relational expressions in this subset.
(package private)  RelSet set
          The set this subset belongs to.
(package private)  long timestamp
          Timestamp for metadata validity
private static Logger tracer
           
 
Fields inherited from class org.eigenbase.rel.AbstractRelNode
digest, id, rowType, traits
 
Fields inherited from interface org.eigenbase.rel.RelNode
emptyArray
 
Constructor Summary
RelSubset(RelOptCluster cluster, RelSet set, RelTraitSet traits)
           
 
Method Summary
(package private)  void add(RelNode rel)
          Adds expression rel to this subset.
(package private)  RelNode buildCheapestPlan(VolcanoPlanner planner)
          Recursively builds a tree consisting of the cheapest plan at each node.
 RelSubset clone()
          A RelSubSet is its own clone.
 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)
           
 RelNode getBest()
           
(package private)  Collection<RelSubset> getParentSubsets()
           
 List<RelNode> getRels()
          Returns the rel nodes in this rel subset.
 double getRows()
          Returns an estimate of the number of rows this relational expression will return.
(package private)  RelSet getSet()
           
 Set<String> getVariablesSet()
          There are no children, as such.
 Set<String> getVariablesUsed()
           
 boolean isDistinct()
          Returns whether the same value will not come out twice.
 void propagateBoostRemoval(VolcanoPlanner planner)
           
(package private)  void propagateCostImprovements(VolcanoPlanner planner, RelNode rel, Set<RelSubset> activeSet)
          Checks whether a relexp has made its subset cheaper, and if it so, recursively checks whether that subset's parents have gotten cheaper.
 
Methods inherited from class org.eigenbase.rel.AbstractRelNode
childrenAccept, cloneTraits, getChildExps, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getInputs, getOrCreateCorrelVariable, getQuery, getRelTypeName, getRowType, getTable, getTraits, getVariablesStopped, inheritTraitsFrom, isAccessTo, isValid, onRegister, recomputeDigest, register, registerCorrelVariable, replaceInput, setCorrelVariable, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tracer

private static final Logger tracer

parents

final List<RelNode> parents
List of the relational expressions for which this subset is an input.


rels

final List<RelNode> rels
The relational expressions in this subset.


bestCost

RelOptCost bestCost
cost of best known plan (it may have improved since)


set

final RelSet set
The set this subset belongs to.


best

RelNode best
best known plan


active

boolean active
whether findBestPlan is being called


timestamp

long timestamp
Timestamp for metadata validity


boosted

boolean boosted
Flag indicating whether this RelSubset's importance was artificially boosted.

Constructor Detail

RelSubset

RelSubset(RelOptCluster cluster,
          RelSet set,
          RelTraitSet traits)
Method Detail

getVariablesSet

public Set<String> getVariablesSet()
There are no children, as such. We throw an exception because you probably don't want to be walking over trees which contain RelSubsets.


getVariablesUsed

public Set<String> getVariablesUsed()

getBest

public RelNode getBest()

clone

public RelSubset clone()
A RelSubSet is its own clone.

Specified by:
clone in interface RelNode
Specified by:
clone in class AbstractRelNode
Returns:
a clone of this RelNode

computeSelfCost

public RelOptCost computeSelfCost(RelOptPlanner planner)
Description copied from interface: RelNode
Returns 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.eigenbase.rel.RelNode), which gives plugins a chance to override the rel's default ideas about cost.

Specified by:
computeSelfCost in interface RelNode
Overrides:
computeSelfCost in class AbstractRelNode

getRows

public double getRows()
Description copied from interface: RelNode
Returns 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.eigenbase.rel.RelNode), which gives plugins a chance to override the rel's default ideas about row count.

Specified by:
getRows in interface RelNode
Overrides:
getRows in class AbstractRelNode

explain

public void explain(RelOptPlanWriter pw)
Specified by:
explain in interface RelNode
Overrides:
explain in class AbstractRelNode

computeDigest

protected String computeDigest()
Description copied from class: AbstractRelNode
Computes the digest. Does not modify this object.

Overrides:
computeDigest in class AbstractRelNode

deriveRowType

protected RelDataType deriveRowType()
Overrides:
deriveRowType in class AbstractRelNode

isDistinct

public boolean isDistinct()
Description copied from interface: RelNode
Returns whether the same value will not come out twice. Default value is false, derived classes should override.

Specified by:
isDistinct in interface RelNode
Overrides:
isDistinct in class AbstractRelNode

getParentSubsets

Collection<RelSubset> getParentSubsets()

getSet

RelSet getSet()

add

void add(RelNode rel)
Adds expression rel to this subset.


buildCheapestPlan

RelNode buildCheapestPlan(VolcanoPlanner planner)
Recursively builds a tree consisting of the cheapest plan at each node.


propagateCostImprovements

void propagateCostImprovements(VolcanoPlanner planner,
                               RelNode rel,
                               Set<RelSubset> activeSet)
Checks whether a relexp has made its subset cheaper, and if it so, recursively checks whether that subset's parents have gotten cheaper.

Parameters:
planner - Planner
rel - Relational expression whose cost has improved
activeSet - Set of active subsets, for cycle detection

propagateBoostRemoval

public void propagateBoostRemoval(VolcanoPlanner planner)

collectVariablesUsed

public void collectVariablesUsed(Set<String> variableSet)
Description copied from interface: RelNode
Collects 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:
collectVariablesUsed in interface RelNode
Overrides:
collectVariablesUsed in class AbstractRelNode
Parameters:
variableSet - receives variables used

collectVariablesSet

public void collectVariablesSet(Set<String> variableSet)
Description copied from interface: RelNode
Collects variables set by this expression.

Specified by:
collectVariablesSet in interface RelNode
Overrides:
collectVariablesSet in class AbstractRelNode
Parameters:
variableSet - receives variables known to be set by

getRels

public List<RelNode> getRels()
Returns the rel nodes in this rel subset. All rels must have the same traits and are logically equivalent.

Returns:
all the rels in the subset