public interface RelOptPlanner
RelOptPlanner is a query optimizer: it transforms a relational
expression into a semantically equivalent relational expression, according to
a given set of rules and a cost model.| Modifier and Type | Interface and Description |
|---|---|
static class |
RelOptPlanner.CannotPlanException
Thrown by
findBestExp(). |
static interface |
RelOptPlanner.Executor
Deprecated.
Use
RexExecutor |
| Modifier and Type | Field and Description |
|---|---|
static org.slf4j.Logger |
LOGGER |
| 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.
|
RelNode |
changeTraits(RelNode rel,
RelTraitSet toTraits)
Changes a relational expression to an equivalent one with a different set
of traits.
|
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.
|
RelTraitSet |
emptyTraitSet()
Creates an empty trait set.
|
RelNode |
ensureRegistered(RelNode rel,
@Nullable RelNode equivRel)
Registers a relational expression if it is not already registered.
|
RelNode |
findBestExp()
Finds the most efficient expression to implement this query.
|
Context |
getContext()
Provides the Context created when this planner was constructed.
|
@Nullable RelOptCost |
getCost(RelNode rel)
Deprecated.
Use
getCost(RelNode, RelMetadataQuery)
or, better, call RelMetadataQuery.getCumulativeCost(RelNode). |
@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.
|
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.
|
@Nullable RelNode |
getRoot()
Returns the root node of this query.
|
List<RelOptRule> |
getRules()
Returns the list of all registered rules.
|
boolean |
isRegistered(RelNode rel)
Determines whether a relational expression has been registered.
|
void |
onCopy(RelNode rel,
RelNode newRel)
Called when a relational expression is copied to a similar expression.
|
void |
prune(RelNode rel)
Prunes a node from the planner.
|
RelNode |
register(RelNode rel,
@Nullable RelNode equivRel)
Registers a relational expression in the expression bank.
|
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)
Deprecated.
Previously, this method installed the cancellation-checking
flag for this planner, but is now deprecated. Now, you should add a
CancelFlag to the Context passed to the constructor. |
void |
setExecutor(@Nullable RexExecutor executor)
Sets the object that can execute scalar expressions.
|
void |
setRoot(RelNode rel)
Sets the root node of this query.
|
void |
setRuleDescExclusionFilter(@Nullable Pattern exclusionFilter)
Sets the exclusion filter to use for this planner.
|
void setRoot(RelNode rel)
rel - Relational expression@Nullable RelNode getRoot()
boolean addRelTraitDef(RelTraitDef relTraitDef)
RelTraitDef has already
been registered, does nothing.Collection.add(E)void clearRelTraitDefs()
List<RelTraitDef> getRelTraitDefs()
void clear()
List<RelOptRule> getRules()
boolean addRule(RelOptRule 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 all
registered RelTraitDef
instances.
Collection.add(E)boolean removeRule(RelOptRule rule)
Collection.remove(Object)Context getContext()
void setRuleDescExclusionFilter(@Nullable Pattern exclusionFilter)
exclusionFilter - pattern to match for exclusion; null to disable
filtering@Deprecated void setCancelFlag(CancelFlag cancelFlag)
CancelFlag to the Context passed to the constructor.cancelFlag - flag which the planner should periodically checkRelNode changeTraits(RelNode rel, RelTraitSet toTraits)
rel - Relational expression (may or may not have been registered; must
not have the desired traits)toTraits - Trait set to convert the relational expression toRelOptPlanner chooseDelegate()
void addMaterialization(RelOptMaterialization materialization)
Typically 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.
List<RelOptMaterialization> getMaterializations()
void addLattice(RelOptLattice lattice)
The lattice may have materializations; it is not necessary to call
addMaterialization(org.apache.calcite.plan.RelOptMaterialization) for these; they are registered implicitly.
@Nullable RelOptLattice getLattice(RelOptTable table)
RelNode findBestExp()
RelOptPlanner.CannotPlanException - if cannot find a planRelOptCostFactory getCostFactory()
RelOptCosts.@Nullable RelOptCost getCost(RelNode rel, RelMetadataQuery mq)
RelMetadataQuery.getCumulativeCost(org.apache.calcite.rel.RelNode).rel - Relational expression of interestmq - Metadata query@Deprecated @Nullable RelOptCost getCost(RelNode rel)
getCost(RelNode, RelMetadataQuery)
or, better, call RelMetadataQuery.getCumulativeCost(RelNode).RelNode register(RelNode rel, @Nullable RelNode equivRel)
After it has been registered, you may not modify it.
The expression must not already have been registered. If you are not
sure whether it has been registered, call
ensureRegistered(RelNode, RelNode).
rel - Relational expression to register (must not already be
registered)equivRel - Relational expression it is equivalent to (may be null)RelNode ensureRegistered(RelNode rel, @Nullable RelNode equivRel)
If equivRel is specified, rel is placed in the same
equivalence set. It is OK if equivRel has different traits;
rel will end up in a different subset of the same set.
It is OK if rel is a subset.
rel - Relational expression to registerequivRel - Relational expression it is equivalent to (may be null)boolean isRegistered(RelNode rel)
rel - expression to testvoid registerSchema(RelOptSchema schema)
void addListener(RelOptListener newListener)
newListener - new listener to be notified of events@Deprecated void registerMetadataProviders(List<RelMetadataProvider> list)
RelMetadataProviders 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.
list - receives planner's custom providers, if any@Deprecated long getRelMetadataTimestamp(RelNode rel)
CachingRelMetadataProvider to decide whether cached metadata has
gone stale.rel - rel of interestvoid prune(RelNode rel)
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.
rel - the node to prune.void registerClass(RelNode node)
node - Relational expressionRelTraitSet emptyTraitSet()
The empty trait set acts as the prototype (a kind of factory) for all subsequently created trait sets.
void setExecutor(@Nullable RexExecutor executor)
@Nullable RexExecutor getExecutor()
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.