Class AbstractRelOptPlanner
- All Implemented Interfaces:
RelOptPlanner
- Direct Known Subclasses:
HepPlanner
,MockRelOptPlanner
,VolcanoPlanner
RelOptPlanner
interface.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.plan.RelOptPlanner
RelOptPlanner.CannotPlanException, RelOptPlanner.Executor
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AtomicBoolean
protected final Context
External context.protected final RelOptCostFactory
protected final Map<String,
RelOptRule> Maps rule description to rule, just to ensure that rules' descriptions are unique.Fields inherited from interface org.apache.calcite.plan.RelOptPlanner
LOGGER
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractRelOptPlanner
(RelOptCostFactory costFactory, @Nullable Context context) Creates an AbstractRelOptPlanner. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Checks to see whether cancellation has been requested, and if so, throws an exception.Negotiates an appropriate planner to deal with distributed queries.void
clear()
Removes all internal state, including all registered rules, materialized views, and lattices.void
Clear all the registered RelTraitDef.protected void
Creates an empty trait set.protected void
fireRule
(RelOptRuleCall ruleCall) Fires a rule, taking care of tracing and listener notification.Provides the Context created when this planner was constructed.@Nullable RelOptCost
Deprecated.@Nullable RelOptCost
getCost
(RelNode rel, RelMetadataQuery mq) Computes the cost of a RelNode.Returns the factory that createsRelOptCost
s.@Nullable RexExecutor
Returns the executor used to evaluate constant expressions.@Nullable RelOptLattice
getLattice
(RelOptTable table) Retrieves a lattice, given its star table.@Nullable RelOptListener
Returns the materializations that have been registered with the planner.long
Deprecated.Returns the list of active trait types.protected @Nullable RelOptRule
getRuleByDescription
(String description) Returns the rule with a given description.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
Called when a relational expression is copied to a similar expression.protected void
onNewClass
(RelNode node) Called when a new class ofRelNode
is seen.void
Prunes a node from the planner.void
registerClass
(RelNode node) Registers a class of RelNode.void
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.subClasses
(Class<? extends RelNode> clazz) Returns sub-classes of relational expression.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.calcite.plan.RelOptPlanner
changeTraits, ensureRegistered, findBestExp, getRoot, isRegistered, register, setRoot
-
Field Details
-
mapDescToRule
Maps rule description to rule, just to ensure that rules' descriptions are unique. -
costFactory
-
cancelFlag
-
context
External context. Never null.
-
-
Constructor Details
-
AbstractRelOptPlanner
Creates an AbstractRelOptPlanner.
-
-
Method Details
-
clear
public void clear()Description copied from interface:RelOptPlanner
Removes all internal state, including all registered rules, materialized views, and lattices.- Specified by:
clear
in interfaceRelOptPlanner
-
getContext
Description copied from interface:RelOptPlanner
Provides the Context created when this planner was constructed.- Specified by:
getContext
in interfaceRelOptPlanner
- Returns:
- Never null; either an externally defined context, or a dummy context that returns null for each requested interface
-
getCostFactory
Description copied from interface:RelOptPlanner
Returns the factory that createsRelOptCost
s.- Specified by:
getCostFactory
in interfaceRelOptPlanner
-
setCancelFlag
Description copied from interface:RelOptPlanner
Does nothing.- Specified by:
setCancelFlag
in interfaceRelOptPlanner
- Parameters:
cancelFlag
- flag which the planner should periodically check
-
checkCancel
public void checkCancel()Checks to see whether cancellation has been requested, and if so, throws an exception. -
getRules
Description copied from interface:RelOptPlanner
Returns the list of all registered rules.- Specified by:
getRules
in interfaceRelOptPlanner
-
addRule
Description copied from interface:RelOptPlanner
Registers a rule.If the rule has already been registered, does nothing. This method determines if the given rule is a
ConverterRule
and pass the ConverterRule to allregistered
RelTraitDef instances.- Specified by:
addRule
in interfaceRelOptPlanner
- Returns:
- whether the rule was added, as per
Collection.add(E)
-
removeRule
Description copied from interface:RelOptPlanner
Removes a rule.- Specified by:
removeRule
in interfaceRelOptPlanner
- Returns:
- true if the rule was present, as per
Collection.remove(Object)
-
getRuleByDescription
Returns the rule with a given description.- Parameters:
description
- Description- Returns:
- Rule with given description, or null if not found
-
setRuleDescExclusionFilter
Description copied from interface:RelOptPlanner
Sets the exclusion filter to use for this planner. Rules which match the given pattern will not be fired regardless of whether or when they are added to the planner.- Specified by:
setRuleDescExclusionFilter
in interfaceRelOptPlanner
- Parameters:
exclusionFilter
- pattern to match for exclusion; null to disable filtering
-
isRuleExcluded
Determines whether a given rule is excluded by ruleDescExclusionFilter.- Parameters:
rule
- rule to test- Returns:
- true iff rule should be excluded
-
chooseDelegate
Description copied from interface:RelOptPlanner
Negotiates an appropriate planner to deal with distributed queries. The idea is that the schemas decide among themselves which has the most knowledge. Right now, the local planner retains control.- Specified by:
chooseDelegate
in interfaceRelOptPlanner
-
addMaterialization
Description copied from interface:RelOptPlanner
Defines a pair of relational expressions that are equivalent.Typically
tableRel
is aLogicalTableScan
representing a table that is a materialized view andqueryRel
is the SQL expression that populates that view. The intention is thattableRel
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 usingtableRel
instead.- Specified by:
addMaterialization
in interfaceRelOptPlanner
-
getMaterializations
Description copied from interface:RelOptPlanner
Returns the materializations that have been registered with the planner.- Specified by:
getMaterializations
in interfaceRelOptPlanner
-
addLattice
Description copied from interface:RelOptPlanner
Defines a lattice.The lattice may have materializations; it is not necessary to call
RelOptPlanner.addMaterialization(org.apache.calcite.plan.RelOptMaterialization)
for these; they are registered implicitly.- Specified by:
addLattice
in interfaceRelOptPlanner
-
getLattice
Description copied from interface:RelOptPlanner
Retrieves a lattice, given its star table.- Specified by:
getLattice
in interfaceRelOptPlanner
-
registerSchema
Description copied from interface:RelOptPlanner
Tells this planner that a schema exists. This is the schema's chance to tell the planner about all of the special transformation rules.- Specified by:
registerSchema
in interfaceRelOptPlanner
-
getRelMetadataTimestamp
Deprecated.Description copied from interface:RelOptPlanner
Gets a timestamp for a given rel's metadata. This timestamp is used byCachingRelMetadataProvider
to decide whether cached metadata has gone stale.- Specified by:
getRelMetadataTimestamp
in interfaceRelOptPlanner
- Parameters:
rel
- rel of interest- Returns:
- timestamp of last change which might affect metadata derivation
-
prune
Description copied from interface:RelOptPlanner
Prunes a node from the planner.When 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.
- Specified by:
prune
in interfaceRelOptPlanner
- Parameters:
rel
- the node to prune.
-
registerClass
Description copied from interface:RelOptPlanner
Registers a class of RelNode. If this class of RelNode has been seen before, does nothing.- Specified by:
registerClass
in interfaceRelOptPlanner
- Parameters:
node
- Relational expression
-
onNewClass
Called when a new class ofRelNode
is seen. -
emptyTraitSet
Description copied from interface:RelOptPlanner
Creates an empty trait set. It contains all registered traits, and the default values of any traits that have them.The empty trait set acts as the prototype (a kind of factory) for all subsequently created trait sets.
- Specified by:
emptyTraitSet
in interfaceRelOptPlanner
- Returns:
- Empty trait set
-
getCost
Description copied from interface:RelOptPlanner
Computes the cost of a RelNode. In most cases, this just dispatches toRelMetadataQuery.getCumulativeCost(org.apache.calcite.rel.RelNode)
.- Specified by:
getCost
in interfaceRelOptPlanner
- Parameters:
rel
- Relational expression of interestmq
- Metadata query- Returns:
- estimated cost
-
getCost
Deprecated.- Specified by:
getCost
in interfaceRelOptPlanner
-
addListener
public void addListener(@UnknownInitialization AbstractRelOptPlanner this, RelOptListener newListener) Description copied from interface:RelOptPlanner
Adds a listener to this planner.- Specified by:
addListener
in interfaceRelOptPlanner
- Parameters:
newListener
- new listener to be notified of events
-
registerMetadataProviders
Deprecated.Description copied from interface:RelOptPlanner
Gives this planner a chance to register one or moreRelMetadataProvider
s 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.
- Specified by:
registerMetadataProviders
in interfaceRelOptPlanner
- Parameters:
list
- receives planner's custom providers, if any
-
addRelTraitDef
Description copied from interface:RelOptPlanner
Registers a rel trait definition. If theRelTraitDef
has already been registered, does nothing.- Specified by:
addRelTraitDef
in interfaceRelOptPlanner
- Returns:
- whether the RelTraitDef was added, as per
Collection.add(E)
-
clearRelTraitDefs
public void clearRelTraitDefs()Description copied from interface:RelOptPlanner
Clear all the registered RelTraitDef.- Specified by:
clearRelTraitDefs
in interfaceRelOptPlanner
-
getRelTraitDefs
Description copied from interface:RelOptPlanner
Returns the list of active trait types.- Specified by:
getRelTraitDefs
in interfaceRelOptPlanner
-
setExecutor
Description copied from interface:RelOptPlanner
Sets the object that can execute scalar expressions.- Specified by:
setExecutor
in interfaceRelOptPlanner
-
getExecutor
Description copied from interface:RelOptPlanner
Returns the executor used to evaluate constant expressions.- Specified by:
getExecutor
in interfaceRelOptPlanner
-
onCopy
Description copied from interface:RelOptPlanner
Called when a relational expression is copied to a similar expression.- Specified by:
onCopy
in interfaceRelOptPlanner
-
dumpRuleAttemptsInfo
protected void dumpRuleAttemptsInfo() -
fireRule
Fires a rule, taking care of tracing and listener notification.- Parameters:
ruleCall
- description of rule call
-
notifyTransformation
Takes care of tracing and listener notification when a rule's transformation is applied.- Parameters:
ruleCall
- description of rule callnewRel
- result of transformationbefore
- true before registration of new rel; false after
-
notifyChosen
Takes care of tracing and listener notification when a rel is chosen as part of the final plan.- Parameters:
rel
- chosen rel
-
notifyEquivalence
Takes care of tracing and listener notification when a rel equivalence is detected.- Parameters:
rel
- chosen rel
-
notifyDiscard
Takes care of tracing and listener notification when a rel is discarded.- Parameters:
rel
- Discarded rel
-
getListener
-
subClasses
Returns sub-classes of relational expression.
-