public abstract class AbstractRelOptPlanner extends Object implements RelOptPlanner
RelOptPlanner interface.RelOptPlanner.CannotPlanException, RelOptPlanner.Executor| Modifier and Type | Field and Description |
|---|---|
protected Context |
context
External context.
|
protected RelOptCostFactory |
costFactory |
LOGGER| Modifier | Constructor and Description |
|---|---|
protected |
AbstractRelOptPlanner(RelOptCostFactory costFactory,
Context context)
Creates an AbstractRelOptPlanner.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLattice(RelOptLattice lattice)
Defines a lattice.
|
void |
addListener(RelOptListener newListener)
Adds a listener to this planner.
|
void |
addMaterialization(RelOptMaterialization materialization)
Defines a pair of relational expressions that are equivalent.
|
boolean |
addRelTraitDef(RelTraitDef relTraitDef)
Registers a rel trait definition.
|
void |
checkCancel()
Checks to see whether cancellation has been requested, and if so, throws
an exception.
|
RelOptPlanner |
chooseDelegate()
Negotiates an appropriate planner to deal with distributed queries.
|
void |
clear()
Removes all internal state, including all rules.
|
void |
clearRelTraitDefs()
Clear all the registered RelTraitDef.
|
RelTraitSet |
emptyTraitSet()
Creates an empty trait set.
|
protected void |
fireRule(RelOptRuleCall ruleCall)
Fires a rule, taking care of tracing and listener notification.
|
Context |
getContext()
Provides the Context created when this planner was constructed.
|
RelOptCost |
getCost(RelNode rel)
Computes the cost of a RelNode.
|
RelOptCostFactory |
getCostFactory()
Returns the factory that creates
RelOptCosts. |
RelOptPlanner.Executor |
getExecutor() |
RelOptLattice |
getLattice(RelOptTable table)
Retrieves a lattice, given its star table.
|
protected MulticastRelOptListener |
getListener() |
long |
getRelMetadataTimestamp(RelNode rel)
Gets a timestamp for a given rel's metadata.
|
List<RelTraitDef> |
getRelTraitDefs()
Returns the list of active trait types.
|
protected RelOptRule |
getRuleByDescription(String description)
Returns the rule with a given description
|
boolean |
isRuleExcluded(RelOptRule rule)
Determines whether a given rule is excluded by ruleDescExclusionFilter.
|
protected void |
mapRuleDescription(RelOptRule rule)
Registers a rule's description.
|
protected void |
notifyChosen(RelNode rel)
Takes care of tracing and listener notification when a rel is chosen as
part of the final plan.
|
protected void |
notifyDiscard(RelNode rel)
Takes care of tracing and listener notification when a rel is discarded
|
protected void |
notifyEquivalence(RelNode rel,
Object equivalenceClass,
boolean physical)
Takes care of tracing and listener notification when a rel equivalence is
detected.
|
protected void |
notifyTransformation(RelOptRuleCall ruleCall,
RelNode newRel,
boolean before)
Takes care of tracing and listener notification when a rule's
transformation is applied.
|
void |
onCopy(RelNode rel,
RelNode newRel)
Called when a relational expression is copied to a similar expression.
|
protected void |
onNewClass(RelNode node)
Called when a new class of
RelNode is seen. |
void |
registerClass(RelNode node)
Registers a class of RelNode.
|
void |
registerMetadataProviders(List<RelMetadataProvider> list)
Gives this planner a chance to register one or more
RelMetadataProviders in the chain which will be used to answer
metadata queries. |
void |
registerSchema(RelOptSchema schema)
Tells this planner that a schema exists.
|
void |
setCancelFlag(CancelFlag cancelFlag)
Installs the cancellation-checking flag for this planner.
|
void |
setExecutor(RelOptPlanner.Executor executor)
Sets the object that can execute scalar expressions.
|
void |
setImportance(RelNode rel,
double importance)
Sets the importance of a relational expression.
|
void |
setRuleDescExclusionFilter(Pattern exclusionFilter)
Sets the exclusion filter to use for this planner.
|
Iterable<Class<? extends RelNode>> |
subClasses(Class<? extends RelNode> clazz)
Returns sub-classes of relational expression.
|
protected void |
unmapRuleDescription(RelOptRule rule)
Removes the mapping between a rule and its description.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddRule, changeTraits, ensureRegistered, findBestExp, getRoot, isRegistered, register, removeRule, setRootprotected final RelOptCostFactory costFactory
protected final Context context
protected AbstractRelOptPlanner(RelOptCostFactory costFactory, Context context)
public void clear()
RelOptPlannerclear in interface RelOptPlannerpublic Context getContext()
RelOptPlannergetContext in interface RelOptPlannerpublic RelOptCostFactory getCostFactory()
RelOptPlannerRelOptCosts.getCostFactory in interface RelOptPlannerpublic void setCancelFlag(CancelFlag cancelFlag)
RelOptPlannersetCancelFlag in interface RelOptPlannercancelFlag - flag which the planner should periodically checkpublic void checkCancel()
protected void mapRuleDescription(RelOptRule rule)
rule - Ruleprotected void unmapRuleDescription(RelOptRule rule)
rule - Ruleprotected RelOptRule getRuleByDescription(String description)
description - Descriptionpublic void setRuleDescExclusionFilter(Pattern exclusionFilter)
RelOptPlannersetRuleDescExclusionFilter in interface RelOptPlannerexclusionFilter - pattern to match for exclusion; null to disable
filteringpublic boolean isRuleExcluded(RelOptRule rule)
rule - rule to testpublic RelOptPlanner chooseDelegate()
RelOptPlannerchooseDelegate in interface RelOptPlannerpublic void addMaterialization(RelOptMaterialization materialization)
RelOptPlannerTypically tableRel is a
LogicalTableScan representing a
table that is a materialized view and queryRel is the SQL
expression that populates that view. The intention is that
tableRel is cheaper to evaluate and therefore if the query being
optimized uses (or can be rewritten to use) queryRel as a
sub-expression then it can be optimized by using tableRel
instead.
addMaterialization in interface RelOptPlannerpublic void addLattice(RelOptLattice lattice)
RelOptPlannerThe lattice may have materializations; it is not necessary to call
RelOptPlanner.addMaterialization(org.apache.calcite.plan.RelOptMaterialization) for these; they are registered implicitly.
addLattice in interface RelOptPlannerpublic RelOptLattice getLattice(RelOptTable table)
RelOptPlannergetLattice in interface RelOptPlannerpublic void registerSchema(RelOptSchema schema)
RelOptPlannerregisterSchema in interface RelOptPlannerpublic long getRelMetadataTimestamp(RelNode rel)
RelOptPlannerCachingRelMetadataProvider to decide whether cached metadata has
gone stale.getRelMetadataTimestamp in interface RelOptPlannerrel - rel of interestpublic void setImportance(RelNode rel, double importance)
RelOptPlannerAn important use of this method is when a RelOptRule has
created a relational expression which is indisputably better than the
original relational expression. The rule set the original relational
expression's importance to zero, to reduce the search space. Pending rule
calls are cancelled, and future rules will not fire.
setImportance in interface RelOptPlannerrel - Relational expressionimportance - Importancepublic void registerClass(RelNode node)
RelOptPlannerregisterClass in interface RelOptPlannernode - Relational expressionpublic RelTraitSet emptyTraitSet()
RelOptPlannerThe empty trait set acts as the prototype (a kind of factory) for all subsequently created trait sets.
emptyTraitSet in interface RelOptPlannerpublic RelOptCost getCost(RelNode rel)
RelOptPlannerRelMetadataQuery.getCumulativeCost(org.apache.calcite.rel.RelNode).getCost in interface RelOptPlannerrel - expression of interestpublic void addListener(RelOptListener newListener)
RelOptPlanneraddListener in interface RelOptPlannernewListener - new listener to be notified of eventspublic void registerMetadataProviders(List<RelMetadataProvider> list)
RelOptPlannerRelMetadataProviders in the chain which will be used to answer
metadata queries.
Planners which use their own relational expressions internally to represent concepts such as equivalence classes will generally need to supply corresponding metadata providers.
registerMetadataProviders in interface RelOptPlannerlist - receives planner's custom providers, if anypublic boolean addRelTraitDef(RelTraitDef relTraitDef)
RelOptPlannerRelTraitDef has already
been registered, does nothing.addRelTraitDef in interface RelOptPlannerCollection.add(E)public void clearRelTraitDefs()
RelOptPlannerclearRelTraitDefs in interface RelOptPlannerpublic List<RelTraitDef> getRelTraitDefs()
RelOptPlannergetRelTraitDefs in interface RelOptPlannerpublic void setExecutor(RelOptPlanner.Executor executor)
RelOptPlannersetExecutor in interface RelOptPlannerpublic RelOptPlanner.Executor getExecutor()
getExecutor in interface RelOptPlannerpublic void onCopy(RelNode rel, RelNode newRel)
RelOptPlanneronCopy in interface RelOptPlannerprotected void fireRule(RelOptRuleCall ruleCall)
ruleCall - description of rule callprotected void notifyTransformation(RelOptRuleCall ruleCall, RelNode newRel, boolean before)
ruleCall - description of rule callnewRel - result of transformationbefore - true before registration of new rel; false afterprotected void notifyChosen(RelNode rel)
rel - chosen relprotected void notifyEquivalence(RelNode rel, Object equivalenceClass, boolean physical)
rel - chosen relprotected void notifyDiscard(RelNode rel)
rel - discarded relprotected MulticastRelOptListener getListener()
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.