Class HepPlanner
- All Implemented Interfaces:
RelOptPlanner
public class HepPlanner extends AbstractRelOptPlanner
RelOptPlanner
interface.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.plan.RelOptPlanner
RelOptPlanner.CannotPlanException, RelOptPlanner.Executor
-
Field Summary
Fields inherited from class org.apache.calcite.plan.AbstractRelOptPlanner
cancelFlag, context, costFactory, mapDescToRule
-
Constructor Summary
Constructors Constructor Description HepPlanner(HepProgram program)
Creates a new HepPlanner that allows DAG.HepPlanner(HepProgram program, Context context)
Creates a new HepPlanner that allows DAG.HepPlanner(HepProgram program, Context context, boolean noDag, Function2<RelNode,RelNode,Void> onCopyHook, RelOptCostFactory costFactory)
Creates a new HepPlanner with the option to keep the graph a tree (noDag = true) or allow DAG (noDag = false). -
Method Summary
Modifier and Type Method Description void
addMaterialization(RelOptMaterialization materialization)
Defines a pair of relational expressions that are equivalent.RelNode
changeTraits(RelNode rel, RelTraitSet toTraits)
Changes a relational expression to an equivalent one with a different set of traits.void
clear()
Removes all internal state, including all registered rules, materialized views, and lattices.RelNode
ensureRegistered(RelNode rel, RelNode equivRel)
Registers a relational expression if it is not already registered.RelNode
findBestExp()
Finds the most efficient expression to implement this query.com.google.common.collect.ImmutableList<RelOptMaterialization>
getMaterializations()
Returns the materializations that have been registered with the planner.long
getRelMetadataTimestamp(RelNode rel)
Gets a timestamp for a given rel's metadata.RelNode
getRoot()
Returns the root node of this query.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.RelNode
register(RelNode rel, RelNode equivRel)
Registers a relational expression in the expression bank.void
registerMetadataProviders(List<RelMetadataProvider> list)
Gives this planner a chance to register one or moreRelMetadataProvider
s in the chain which will be used to answer metadata queries.void
setRoot(RelNode rel)
Sets the root node of this query.Methods inherited from class org.apache.calcite.plan.AbstractRelOptPlanner
addLattice, addListener, addRelTraitDef, addRule, checkCancel, chooseDelegate, clearRelTraitDefs, dumpRuleAttemptsInfo, emptyTraitSet, fireRule, getContext, getCost, getCost, getCostFactory, getExecutor, getLattice, getListener, getRelTraitDefs, getRuleByDescription, getRules, isRuleExcluded, notifyChosen, notifyDiscard, notifyEquivalence, notifyTransformation, onNewClass, prune, registerClass, registerSchema, removeRule, setCancelFlag, setExecutor, setRuleDescExclusionFilter, subClasses
-
Constructor Details
-
HepPlanner
Creates a new HepPlanner that allows DAG.- Parameters:
program
- program controlling rule application
-
HepPlanner
Creates a new HepPlanner that allows DAG.- Parameters:
program
- program controlling rule applicationcontext
- to carry while planning
-
HepPlanner
public HepPlanner(HepProgram program, Context context, boolean noDag, Function2<RelNode,RelNode,Void> onCopyHook, RelOptCostFactory costFactory)Creates a new HepPlanner with the option to keep the graph a tree (noDag = true) or allow DAG (noDag = false).- Parameters:
noDag
- If false, create shared nodes if expressions are identicalprogram
- Program controlling rule applicationonCopyHook
- Function to call when a node is copied
-
-
Method Details
-
setRoot
Description copied from interface:RelOptPlanner
Sets the root node of this query.- Parameters:
rel
- Relational expression
-
getRoot
Description copied from interface:RelOptPlanner
Returns the root node of this query.- Returns:
- Root node
-
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
- Overrides:
clear
in classAbstractRelOptPlanner
-
changeTraits
Description copied from interface:RelOptPlanner
Changes a relational expression to an equivalent one with a different set of traits.- Parameters:
rel
- Relational expression (may or may not have been registered; must not have the desired traits)toTraits
- Trait set to convert the relational expression to- Returns:
- Relational expression with desired traits. Never null, but may be abstract
-
findBestExp
Description copied from interface:RelOptPlanner
Finds the most efficient expression to implement this query. -
register
Description copied from interface:RelOptPlanner
Registers a relational expression in the expression bank.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
RelOptPlanner.ensureRegistered(RelNode, RelNode)
.- Parameters:
rel
- Relational expression to register (must not already be registered)equivRel
- Relational expression it is equivalent to (may be null)- Returns:
- the same expression, or an equivalent existing expression
-
onCopy
Description copied from interface:RelOptPlanner
Called when a relational expression is copied to a similar expression.- Specified by:
onCopy
in interfaceRelOptPlanner
- Overrides:
onCopy
in classAbstractRelOptPlanner
-
ensureRegistered
Description copied from interface:RelOptPlanner
Registers a relational expression if it is not already registered.If
equivRel
is specified,rel
is placed in the same equivalence set. It is OK ifequivRel
has different traits;rel
will end up in a different subset of the same set.It is OK if
rel
is a subset.- Parameters:
rel
- Relational expression to registerequivRel
- Relational expression it is equivalent to (may be null)- Returns:
- Registered relational expression
-
isRegistered
Description copied from interface:RelOptPlanner
Determines whether a relational expression has been registered.- Parameters:
rel
- expression to test- Returns:
- whether rel has been registered
-
registerMetadataProviders
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
- Overrides:
registerMetadataProviders
in classAbstractRelOptPlanner
- Parameters:
list
- receives planner's custom providers, if any
-
getRelMetadataTimestamp
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
- Overrides:
getRelMetadataTimestamp
in classAbstractRelOptPlanner
- Parameters:
rel
- rel of interest- Returns:
- timestamp of last change which might affect metadata derivation
-
getMaterializations
Description copied from interface:RelOptPlanner
Returns the materializations that have been registered with the planner.- Specified by:
getMaterializations
in interfaceRelOptPlanner
- Overrides:
getMaterializations
in classAbstractRelOptPlanner
-
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
- Overrides:
addMaterialization
in classAbstractRelOptPlanner
-