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
FieldsModifier and TypeFieldDescriptionprotected final AtomicBooleanprotected final ContextExternal context.protected final RelOptCostFactoryprotected 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
ConstructorsModifierConstructorDescriptionprotectedAbstractRelOptPlanner(RelOptCostFactory costFactory, @Nullable Context context) Creates an AbstractRelOptPlanner. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLattice(RelOptLattice lattice) Defines a lattice.voidaddListener(RelOptListener newListener) Adds a listener to this planner.voidaddMaterialization(RelOptMaterialization materialization) Defines a pair of relational expressions that are equivalent.booleanaddRelTraitDef(RelTraitDef relTraitDef) Registers a rel trait definition.booleanaddRule(RelOptRule rule) Registers a rule.voidChecks to see whether cancellation has been requested, and if so, throws an exception.Negotiates an appropriate planner to deal with distributed queries.voidclear()Removes all internal state, including all registered rules, materialized views, and lattices.voidClear all the registered RelTraitDef.protected voidCreates an empty trait set.protected voidfireRule(RelOptRuleCall ruleCall) Fires a rule, taking care of tracing and listener notification.Provides the Context created when this planner was constructed.@Nullable RelOptCostDeprecated.@Nullable RelOptCostgetCost(RelNode rel, RelMetadataQuery mq) Computes the cost of a RelNode.Returns the factory that createsRelOptCosts.Returns the decorrelator used to decorrelate expressions.@Nullable RexExecutorReturns the executor used to evaluate constant expressions.@Nullable RelOptLatticegetLattice(RelOptTable table) Retrieves a lattice, given its star table.@Nullable RelOptListenerReturns the materializations that have been registered with the planner.longDeprecated.Returns the list of active trait types.protected @Nullable RelOptRulegetRuleByDescription(String description) Returns the rule with a given description.getRules()Returns the list of all registered rules.booleanisRuleExcluded(RelOptRule rule) Determines whether a given rule is excluded by ruleDescExclusionFilter.protected voidnotifyChosen(RelNode rel) Takes care of tracing and listener notification when a rel is chosen as part of the final plan.protected voidnotifyDiscard(RelNode rel) Takes care of tracing and listener notification when a rel is discarded.protected voidnotifyEquivalence(RelNode rel, Object equivalenceClass, boolean physical) Takes care of tracing and listener notification when a rel equivalence is detected.protected voidnotifyTransformation(RelOptRuleCall ruleCall, RelNode newRel, boolean before) Takes care of tracing and listener notification when a rule's transformation is applied.voidCalled when a relational expression is copied to a similar expression.protected voidonNewClass(RelNode node) Called when a new class ofRelNodeis seen.voidPrunes a node from the planner.voidregisterClass(RelNode node) Registers a class of RelNode.voidDeprecated.voidregisterSchema(RelOptSchema schema) Tells this planner that a schema exists.booleanremoveRule(RelOptRule rule) Removes a rule.voidsetCancelFlag(CancelFlag cancelFlag) Does nothing.voidsetDecorrelator(@Nullable RelDecorrelator decorrelator) Sets the decorrelator.voidsetExecutor(@Nullable RexExecutor executor) Sets the object that can execute scalar expressions.voidsetRuleDescExclusionFilter(@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, waitMethods 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:RelOptPlannerRemoves all internal state, including all registered rules, materialized views, and lattices.- Specified by:
clearin interfaceRelOptPlanner
-
getContext
Description copied from interface:RelOptPlannerProvides the Context created when this planner was constructed.- Specified by:
getContextin 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:RelOptPlannerReturns the factory that createsRelOptCosts.- Specified by:
getCostFactoryin interfaceRelOptPlanner
-
setCancelFlag
Description copied from interface:RelOptPlannerDoes nothing.- Specified by:
setCancelFlagin 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:RelOptPlannerReturns the list of all registered rules.- Specified by:
getRulesin interfaceRelOptPlanner
-
addRule
Description copied from interface:RelOptPlannerRegisters a rule.If the rule has already been registered, does nothing. This method determines if the given rule is a
ConverterRuleand pass the ConverterRule to allregisteredRelTraitDef instances.- Specified by:
addRulein interfaceRelOptPlanner- Returns:
- whether the rule was added, as per
Collection.add(E)
-
removeRule
Description copied from interface:RelOptPlannerRemoves a rule.- Specified by:
removeRulein 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:RelOptPlannerSets 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:
setRuleDescExclusionFilterin 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:RelOptPlannerNegotiates 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:
chooseDelegatein interfaceRelOptPlanner
-
addMaterialization
Description copied from interface:RelOptPlannerDefines a pair of relational expressions that are equivalent.Typically
tableRelis aLogicalTableScanrepresenting a table that is a materialized view andqueryRelis the SQL expression that populates that view. The intention is thattableRelis cheaper to evaluate and therefore if the query being optimized uses (or can be rewritten to use)queryRelas a sub-expression then it can be optimized by usingtableRelinstead.- Specified by:
addMaterializationin interfaceRelOptPlanner
-
getMaterializations
Description copied from interface:RelOptPlannerReturns the materializations that have been registered with the planner.- Specified by:
getMaterializationsin interfaceRelOptPlanner
-
addLattice
Description copied from interface:RelOptPlannerDefines 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:
addLatticein interfaceRelOptPlanner
-
getLattice
Description copied from interface:RelOptPlannerRetrieves a lattice, given its star table.- Specified by:
getLatticein interfaceRelOptPlanner
-
registerSchema
Description copied from interface:RelOptPlannerTells 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:
registerSchemain interfaceRelOptPlanner
-
getRelMetadataTimestamp
Deprecated.Description copied from interface:RelOptPlannerGets a timestamp for a given rel's metadata. This timestamp is used byCachingRelMetadataProviderto decide whether cached metadata has gone stale.- Specified by:
getRelMetadataTimestampin interfaceRelOptPlanner- Parameters:
rel- rel of interest- Returns:
- timestamp of last change which might affect metadata derivation
-
prune
Description copied from interface:RelOptPlannerPrunes 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:
prunein interfaceRelOptPlanner- Parameters:
rel- the node to prune.
-
registerClass
Description copied from interface:RelOptPlannerRegisters a class of RelNode. If this class of RelNode has been seen before, does nothing.- Specified by:
registerClassin interfaceRelOptPlanner- Parameters:
node- Relational expression
-
onNewClass
Called when a new class ofRelNodeis seen. -
emptyTraitSet
Description copied from interface:RelOptPlannerCreates 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:
emptyTraitSetin interfaceRelOptPlanner- Returns:
- Empty trait set
-
getCost
Description copied from interface:RelOptPlannerComputes the cost of a RelNode. In most cases, this just dispatches toRelMetadataQuery.getCumulativeCost(org.apache.calcite.rel.RelNode).- Specified by:
getCostin interfaceRelOptPlanner- Parameters:
rel- Relational expression of interestmq- Metadata query- Returns:
- estimated cost
-
getCost
Deprecated.- Specified by:
getCostin interfaceRelOptPlanner
-
addListener
public void addListener(@UnknownInitialization AbstractRelOptPlanner this, RelOptListener newListener) Description copied from interface:RelOptPlannerAdds a listener to this planner.- Specified by:
addListenerin interfaceRelOptPlanner- Parameters:
newListener- new listener to be notified of events
-
registerMetadataProviders
Deprecated.Description copied from interface:RelOptPlannerGives this planner a chance to register one or moreRelMetadataProviders 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:
registerMetadataProvidersin interfaceRelOptPlanner- Parameters:
list- receives planner's custom providers, if any
-
addRelTraitDef
Description copied from interface:RelOptPlannerRegisters a rel trait definition. If theRelTraitDefhas already been registered, does nothing.- Specified by:
addRelTraitDefin interfaceRelOptPlanner- Returns:
- whether the RelTraitDef was added, as per
Collection.add(E)
-
clearRelTraitDefs
public void clearRelTraitDefs()Description copied from interface:RelOptPlannerClear all the registered RelTraitDef.- Specified by:
clearRelTraitDefsin interfaceRelOptPlanner
-
getRelTraitDefs
Description copied from interface:RelOptPlannerReturns the list of active trait types.- Specified by:
getRelTraitDefsin interfaceRelOptPlanner
-
setExecutor
Description copied from interface:RelOptPlannerSets the object that can execute scalar expressions.- Specified by:
setExecutorin interfaceRelOptPlanner
-
getExecutor
Description copied from interface:RelOptPlannerReturns the executor used to evaluate constant expressions.- Specified by:
getExecutorin interfaceRelOptPlanner
-
setDecorrelator
Description copied from interface:RelOptPlannerSets the decorrelator.- Specified by:
setDecorrelatorin interfaceRelOptPlanner
-
getDecorrelator
Description copied from interface:RelOptPlannerReturns the decorrelator used to decorrelate expressions.- Specified by:
getDecorrelatorin interfaceRelOptPlanner
-
onCopy
Description copied from interface:RelOptPlannerCalled when a relational expression is copied to a similar expression.- Specified by:
onCopyin 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.
-