public abstract class AbstractRelOptPlanner extends Object implements RelOptPlanner
RelOptPlanner interface.RelOptPlanner.CannotPlanException, RelOptPlanner.Executor| Modifier and Type | Field and Description |
|---|---|
protected AtomicBoolean |
cancelFlag |
protected Context |
context
External context.
|
protected RelOptCostFactory |
costFactory |
protected Map<String,RelOptRule> |
mapDescToRule
Maps rule description to rule, just to ensure that rules' descriptions
are unique.
|
LOGGER| Modifier | Constructor and Description |
|---|---|
protected |
AbstractRelOptPlanner(RelOptCostFactory costFactory,
@Nullable 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.
|
boolean |
addRule(RelOptRule rule)
Registers a rule.
|
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 registered rules,
materialized views, and lattices.
|
void |
clearRelTraitDefs()
Clear all the registered RelTraitDef.
|
protected void |
dumpRuleAttemptsInfo() |
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.
|
@Nullable RelOptCost |
getCost(RelNode rel)
Deprecated.
|
@Nullable RelOptCost |
getCost(RelNode rel,
RelMetadataQuery mq)
Computes the cost of a RelNode.
|
RelOptCostFactory |
getCostFactory()
Returns the factory that creates
RelOptCosts. |
@Nullable RexExecutor |
getExecutor()
Returns the executor used to evaluate constant expressions.
|
@Nullable RelOptLattice |
getLattice(RelOptTable table)
Retrieves a lattice, given its star table.
|
@Nullable RelOptListener |
getListener() |
List<RelOptMaterialization> |
getMaterializations()
Returns the materializations that have been registered with the planner.
|
long |
getRelMetadataTimestamp(RelNode rel)
Deprecated.
|
List<RelTraitDef> |
getRelTraitDefs()
Returns the list of active trait types.
|
protected @Nullable RelOptRule |
getRuleByDescription(String description)
Returns the rule with a given description.
|
List<RelOptRule> |
getRules()
Returns the list of all registered rules.
|
boolean |
isRuleExcluded(RelOptRule rule)
Determines whether a given rule is excluded by ruleDescExclusionFilter.
|
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 |
prune(RelNode rel)
Prunes a node from the planner.
|
void |
registerClass(RelNode node)
Registers a class of RelNode.
|
void |
registerMetadataProviders(List<RelMetadataProvider> list)
Deprecated.
|
void |
registerSchema(RelOptSchema schema)
Tells this planner that a schema exists.
|
boolean |
removeRule(RelOptRule rule)
Removes a rule.
|
void |
setCancelFlag(CancelFlag cancelFlag)
Does nothing.
|
void |
setExecutor(@Nullable RexExecutor executor)
Sets the object that can execute scalar expressions.
|
void |
setRuleDescExclusionFilter(@Nullable 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitchangeTraits, ensureRegistered, findBestExp, getRoot, isRegistered, register, setRootprotected final Map<String,RelOptRule> mapDescToRule
protected final RelOptCostFactory costFactory
protected final AtomicBoolean cancelFlag
protected final Context context
protected AbstractRelOptPlanner(RelOptCostFactory costFactory, @Nullable 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()
public List<RelOptRule> getRules()
RelOptPlannergetRules in interface RelOptPlannerpublic boolean addRule(RelOptRule rule)
RelOptPlannerIf the rule has already been registered, does nothing.
This method determines if the given rule is a
ConverterRule and pass the
ConverterRule to all
registered RelTraitDef
instances.
addRule in interface RelOptPlannerCollection.add(E)public boolean removeRule(RelOptRule rule)
RelOptPlannerremoveRule in interface RelOptPlannerCollection.remove(Object)protected @Nullable RelOptRule getRuleByDescription(String description)
description - Descriptionpublic void setRuleDescExclusionFilter(@Nullable 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 List<RelOptMaterialization> getMaterializations()
RelOptPlannergetMaterializations 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 @Nullable RelOptLattice getLattice(RelOptTable table)
RelOptPlannergetLattice in interface RelOptPlannerpublic void registerSchema(RelOptSchema schema)
RelOptPlannerregisterSchema in interface RelOptPlanner@Deprecated public long getRelMetadataTimestamp(RelNode rel)
RelOptPlannerCachingRelMetadataProvider to decide whether cached metadata has
gone stale.getRelMetadataTimestamp in interface RelOptPlannerrel - rel of interestpublic void prune(RelNode rel)
RelOptPlannerWhen a node is pruned, the related pending rule calls are cancelled, and future rules will not fire. This can be used to reduce the search space.
prune in interface RelOptPlannerrel - the node to prune.public 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 @Nullable RelOptCost getCost(RelNode rel, RelMetadataQuery mq)
RelOptPlannerRelMetadataQuery.getCumulativeCost(org.apache.calcite.rel.RelNode).getCost in interface RelOptPlannerrel - Relational expression of interestmq - Metadata query@Deprecated public @Nullable RelOptCost getCost(RelNode rel)
getCost in interface RelOptPlannerpublic void addListener(@UnknownInitialization AbstractRelOptPlanner this,
RelOptListener newListener)
RelOptPlanneraddListener in interface RelOptPlannernewListener - new listener to be notified of events@Deprecated public 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(@Nullable RexExecutor executor)
RelOptPlannersetExecutor in interface RelOptPlannerpublic @Nullable RexExecutor getExecutor()
RelOptPlannergetExecutor in interface RelOptPlannerpublic void onCopy(RelNode rel, RelNode newRel)
RelOptPlanneronCopy in interface RelOptPlannerprotected void dumpRuleAttemptsInfo()
protected 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 rel@Pure public @Nullable RelOptListener getListener()
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.