public class RelSubset extends AbstractRelNode
Physical properties are instances of the RelTraitSet, and consist
of traits such as calling convention and collation (sort-order).
For some traits, a relational expression can have more than one instance. For example, R can be sorted on both [X] and [Y, Z]. In which case, R would belong to the sub-sets for [X] and [Y, Z]; and also the leading edges [Y] and [].
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
RelSubset.CheapestPlanReplacer
Visitor which walks over a tree of
RelSets, replacing each node
with the cheapest implementation of the expression. |
RelNode.Context| Modifier and Type | Field and Description |
|---|---|
(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.
|
private static org.slf4j.Logger |
LOGGER |
(package private) RelSet |
set
The set this subset belongs to.
|
(package private) long |
timestamp
Timestamp for metadata validity
|
digest, id, rowType, traitSet| Constructor and Description |
|---|
RelSubset(RelOptCluster cluster,
RelSet set,
RelTraitSet traits) |
| Modifier and Type | Method and Description |
|---|---|
(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.
|
void |
collectVariablesSet(Set<CorrelationId> variableSet)
Collects variables set by this expression.
|
void |
collectVariablesUsed(Set<CorrelationId> variableSet)
Collects variables known to be used by this expression or its
descendants.
|
private void |
computeBestCost(RelOptPlanner planner)
Computes the best
RelNode in this subset. |
protected String |
computeDigest()
Computes the digest.
|
RelOptCost |
computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq)
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() |
double |
estimateRowCount(RelMetadataQuery mq)
Returns an estimate of the number of rows this relational expression will
return.
|
void |
explain(RelWriter pw)
Describes the inputs and attributes of this relational expression.
|
RelNode |
getBest() |
RelNode |
getOriginal() |
Collection<RelNode> |
getParentRels()
Returns a list of relational expressions one of whose children is this
subset.
|
(package private) Set<RelNode> |
getParents()
Returns the collection of RelNodes one of whose inputs is in this
subset.
|
(package private) Set<RelSubset> |
getParentSubsets(VolcanoPlanner planner)
Returns the collection of distinct subsets that contain a RelNode one
of whose inputs is in this subset.
|
List<RelNode> |
getRelList()
As
getRels() but returns a list. |
Iterable<RelNode> |
getRels()
Returns the rel nodes in this rel subset.
|
(package private) RelSet |
getSet() |
private static List<RelSubset> |
inputSubsets(RelNode parent) |
void |
propagateBoostRemoval(VolcanoPlanner planner) |
(package private) void |
propagateCostImprovements(VolcanoPlanner planner,
RelMetadataQuery mq,
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.
|
(package private) void |
propagateCostImprovements0(VolcanoPlanner planner,
RelMetadataQuery mq,
RelNode rel,
Set<RelSubset> activeSet) |
accept, accept, childrenAccept, computeSelfCost, explainTerms, getChildExps, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getInputs, getQuery, getRelTypeName, getRows, getRowType, getTable, getTraitSet, getVariablesSet, getVariablesStopped, isDistinct, isKey, isValid, isValid, metadata, onRegister, recomputeDigest, register, replaceInput, sole, toStringprivate static final org.slf4j.Logger LOGGER
RelOptCost bestCost
final RelSet set
RelNode best
long timestamp
boolean boosted
RelSubset(RelOptCluster cluster, RelSet set, RelTraitSet traits)
private void computeBestCost(RelOptPlanner planner)
RelNode in this subset.
Only necessary when a subset is created in a set that has subsets that subsume it. Rationale:
best and bestCost are maintained
incrementally by propagateCostImprovements0(org.apache.calcite.plan.volcano.VolcanoPlanner, org.apache.calcite.rel.metadata.RelMetadataQuery, org.apache.calcite.rel.RelNode, java.util.Set<org.apache.calcite.plan.volcano.RelSubset>) and
RelSet.mergeWith(VolcanoPlanner, RelSet).public RelNode getBest()
public RelNode getOriginal()
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.
copy in interface RelNodecopy in class AbstractRelNodetraitSet - Trait setinputs - Inputspublic RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
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 RelNodecomputeSelfCost in class AbstractRelNodeplanner - Planner for cost calculationmq - Metadata querypublic double estimateRowCount(RelMetadataQuery mq)
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.
estimateRowCount in interface RelNodeestimateRowCount in class AbstractRelNodemq - Metadata querypublic void explain(RelWriter pw)
RelNodesuper.explain, then call the
RelWriterImpl.input(String, RelNode)
and
RelWriterImpl.item(String, Object)
methods for each input and attribute.explain in interface RelNodeexplain in class AbstractRelNodepw - Plan writerprotected String computeDigest()
AbstractRelNodecomputeDigest in class AbstractRelNodeprotected RelDataType deriveRowType()
deriveRowType in class AbstractRelNodeSet<RelNode> getParents()
Set<RelSubset> getParentSubsets(VolcanoPlanner planner)
public Collection<RelNode> getParentRels()
RelSet getSet()
void add(RelNode rel)
rel to this subset.RelNode buildCheapestPlan(VolcanoPlanner planner)
void propagateCostImprovements(VolcanoPlanner planner, RelMetadataQuery mq, RelNode rel, Set<RelSubset> activeSet)
planner - Plannermq - Metadata queryrel - Relational expression whose cost has improvedactiveSet - Set of active subsets, for cycle detectionvoid propagateCostImprovements0(VolcanoPlanner planner, RelMetadataQuery mq, RelNode rel, Set<RelSubset> activeSet)
public void propagateBoostRemoval(VolcanoPlanner planner)
public void collectVariablesUsed(Set<CorrelationId> variableSet)
RelNodecollectVariablesUsed in interface RelNodecollectVariablesUsed in class AbstractRelNodevariableSet - receives variables usedpublic void collectVariablesSet(Set<CorrelationId> variableSet)
RelNodecollectVariablesSet in interface RelNodecollectVariablesSet in class AbstractRelNodevariableSet - receives variables known to be set bypublic Iterable<RelNode> getRels()
Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.