|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.relopt.volcano.RuleQueue
class RuleQueue
Priority queue of relexps whose rules have not been called, and rule-matches which have not yet been acted upon.
Nested Class Summary | |
---|---|
private static class |
RuleQueue.PhaseMatchList
PhaseMatchList represents a set of rule-matches
for a particular phase of the planner's
execution . |
private class |
RuleQueue.RelImportanceComparator
Compares RelNode objects according to their cached 'importance'. |
private class |
RuleQueue.RuleMatchImportanceComparator
Compares VolcanoRuleMatch objects according to their importance. |
Field Summary | |
---|---|
private static Set<String> |
allRules
|
(package private) Set<RelSubset> |
boostedSubsets
The set of RelSubsets whose importance is currently in an artificially raised state. |
(package private) Map<VolcanoPlannerPhase,RuleQueue.PhaseMatchList> |
matchListMap
Map of VolcanoPlannerPhase to a list of rule-matches. |
private static double |
OneMinusEpsilon
Largest value which is less than one. |
private Map<VolcanoPlannerPhase,Set<String>> |
phaseRuleMapping
|
private VolcanoPlanner |
planner
|
private Comparator<RelSubset> |
relImportanceComparator
Compares relexps according to their cached 'importance'. |
private Comparator<VolcanoRuleMatch> |
ruleMatchImportanceComparator
Sorts rule-matches into decreasing order of importance. |
(package private) Map<RelSubset,Double> |
subsetImportances
The importance of each subset. |
private static Logger |
tracer
|
Constructor Summary | |
---|---|
RuleQueue(VolcanoPlanner planner)
|
Method Summary | |
---|---|
(package private) void |
addMatch(VolcanoRuleMatch match)
Adds a rule match. |
void |
boostImportance(Collection<RelSubset> subsets,
double factor)
Artificially boosts the importance of the given RelSubset s by a
given factor. |
(package private) static int |
compareRels(RelNode[] rels0,
RelNode[] rels1)
|
(package private) double |
computeImportance(RelSubset subset)
Computes the importance of a node. |
private double |
computeImportanceOfChild(RelSubset child,
RelSubset parent)
Returns the importance of a child to a parent. |
private static double |
computeOneMinusEpsilon()
|
private void |
dump()
|
private void |
dump(PrintWriter pw)
|
double |
getImportance(RelSet set)
Computes the importance of a set (which is that of its most important subset). |
(package private) double |
getImportance(RelSubset rel)
Returns the importance of an equivalence class of relational expressions. |
boolean |
hasNextMatch(VolcanoPlannerPhase phase)
Returns whether there is a rule match in the queue for the given phase. |
void |
phaseCompleted(VolcanoPlannerPhase phase)
Removes the rule-match list for the given planner
phase. |
(package private) VolcanoRuleMatch |
popMatch(VolcanoPlannerPhase phase)
Removes the rule match with the highest importance, and returns it. |
void |
recompute(RelSubset subset)
Equivalent to recompute(subset,
false) . |
void |
recompute(RelSubset subset,
boolean force)
Recomputes the importance of the given RelSubset. |
private double |
toDouble(RelOptCost cost)
Converts a cost to a scalar quantity. |
(package private) void |
updateImportance(RelSubset subset,
Double importance)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger tracer
private static final Set<String> allRules
private static final double OneMinusEpsilon
final Map<RelSubset,Double> subsetImportances
final Set<RelSubset> boostedSubsets
final Map<VolcanoPlannerPhase,RuleQueue.PhaseMatchList> matchListMap
VolcanoPlannerPhase
to a list of rule-matches. Initially,
there is an empty RuleQueue.PhaseMatchList
for each planner phase. As the
planner invokes addMatch(VolcanoRuleMatch)
the rule-match is
added to the appropriate PhaseMatchList(s). As the planner completes
phases, the matching entry is removed from this list to avoid unused
work.
private final Comparator<VolcanoRuleMatch> ruleMatchImportanceComparator
private final VolcanoPlanner planner
private final Comparator<RelSubset> relImportanceComparator
private final Map<VolcanoPlannerPhase,Set<String>> phaseRuleMapping
Constructor Detail |
---|
RuleQueue(VolcanoPlanner planner)
Method Detail |
---|
public void phaseCompleted(VolcanoPlannerPhase phase)
rule-match list
for the given planner
phase.
public double getImportance(RelSet set)
public boolean hasNextMatch(VolcanoPlannerPhase phase)
Note that the VolcanoPlanner may still decide to reject rule matches which have become invalid, say if one of their operands belongs to an obsolete set or has importance=0.
NullPointerException
- if this method is called with a phase
previously marked as completed via phaseCompleted(VolcanoPlannerPhase)
.public void recompute(RelSubset subset, boolean force)
subset
- RelSubset whose importance is to be recomputedforce
- if true, forces an importance update even if the subset has
not been registeredpublic void recompute(RelSubset subset)
recompute(subset,
false)
.
public void boostImportance(Collection<RelSubset> subsets, double factor)
RelSubset
s by a
given factor.
Iterates over the currently boosted RelSubsets and removes their
importance boost, forcing a recalculation of the RelSubsets' importances
(see recompute(RelSubset)
).
Once RelSubsets have been restored to their normal importance, the given RelSubsets have their importances boosted. A RelSubset's boosted importance is always less than 1.0 (and never equal to 1.0).
subsets
- RelSubsets to boost importance (priority)factor
- the amount to boost their importances (e.g., 1.25 increases
importance by 25%)void updateImportance(RelSubset subset, Double importance)
double getImportance(RelSubset rel)
If a subset in the same set but with a different calling convention is deemed to be important, then this subset has at least half of its importance. (This rule is designed to encourage conversions to take place.)
void addMatch(VolcanoRuleMatch match)
per-phase rule-match lists
which allow
the rule referenced by the match.
double computeImportance(RelSubset subset)
RelSubset
has an importance of 1In = Sumparents p of n{Ip . W n, p}where Wn, p, the weight of n within its parent p, is
Wn, p = Costn / (SelfCostp + Costn0 + ... + Costnk)
private void dump()
private void dump(PrintWriter pw)
VolcanoRuleMatch popMatch(VolcanoPlannerPhase phase)
private double computeImportanceOfChild(RelSubset child, RelSubset parent)
private double toDouble(RelOptCost cost)
static int compareRels(RelNode[] rels0, RelNode[] rels1)
private static double computeOneMinusEpsilon()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |