|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--saffron.opt.VolcanoPlanner
VolcanoPlanner optimizes queries by transforming expressions selectively according to a dynamic programming algorithm.
Nested Class Summary | |
private static class |
VolcanoPlanner.DeferringRuleCall
A rule call which defers its actions. |
Field Summary | |
(package private) ArrayList |
allOperands
List of all operands of all rules. |
(package private) ArrayList |
allSets
List of all sets. |
private ArrayList |
callingConventions
|
private Graph |
conversionGraph
|
private MultiMap |
mapArcToConverterRule
For a given source/target convention, there may be several possible conversion rules. |
private HashMap |
mapDescToRule
Maps rule description to rule, just to ensure that rules' descriptions are unique. |
(package private) HashMap |
mapDigestToRel
Canonical map from digest to the unique
relational expression with that digest. |
(package private) HashMap |
mapRel2Subset
Map each registered expression ( Rel ) to its
equivalence set (RelSubset ). |
private int |
nextSetId
|
private int |
registerCount
Incremented every time a relational expression is registered or two sets are merged. |
(package private) HashSet |
registeredSchemas
List of all schemas which have been registered. |
protected RelSubset |
root
|
(package private) RuleQueue |
ruleQueue
Holds rule calls waiting to be fired. |
Constructor Summary | |
(package private) |
VolcanoPlanner()
Creates a VolcanoPlanner . |
Method Summary | |
void |
addCallingConvention(CallingConvention convention)
Registers a calling convention. |
void |
addRule(Rule rule)
Registers a rule. |
boolean |
canConvert(CallingConvention fromConvention,
CallingConvention toConvention)
|
private RelSubset |
canonize(RelSubset subset)
|
Rel |
changeConvention(Rel rel,
CallingConvention toConvention)
Changes a relational expression to an equivalent one of a different calling convention. |
private Rel |
changeConvention(Rel rel,
Graph.Arc arc)
Tries to convert a relational expression to the target convention of an arc. |
(package private) Rel |
changeConventionUsingConverters(Rel rel,
CallingConvention toConvention)
|
(package private) void |
checkForSatisfiedConverters(RelSet set,
Rel rel)
|
Planner |
chooseDelegate()
Negotiates an appropriate planner to deal with distributed queries. |
(package private) void |
dump()
|
Rel |
findBestExp()
Find the most efficient expression to implement this query. |
private RelSubset |
findBestPlan_old(RelSubset subset,
Cost targetCost)
|
private void |
fireRules(Rel rel,
boolean deferred)
Fire all rules matched by a relational expression. |
private void |
fireRulesForSubset(RelSubset childSubset)
|
private boolean |
fixupInputs(Rel rel)
|
Operand[] |
getConversionOperands(CallingConvention toConvention)
|
(package private) Cost |
getCost(Rel rel)
Finds the cost of a node. |
Rel |
getRoot()
|
RelSet |
getSet(Rel rel)
Find an expression's equivalence set. |
(package private) RelSubset |
getSubset(Rel rel)
|
(package private) RelSubset |
getSubset(Rel rel,
CallingConvention convention)
|
(package private) void |
init()
Initializes the rule set. |
boolean |
isRegistered(Rel rel)
|
Cost |
makeCost(double dRows,
double dCpu,
double dIo)
Create a cost object. |
Cost |
makeHugeCost()
Create a cost object representing infinite cost. |
Cost |
makeInfiniteCost()
Create a cost object representing infinite cost. |
Cost |
makeTinyCost()
Create a cost object representing a small positive cost. |
Cost |
makeZeroCost()
Create a cost object representing zero cost. |
private void |
merge(RelSet set,
RelSet set2)
|
private Cost |
optimize(Rel rel,
Cost targetCost)
By optimizing its children, find the best implementation of relational expression rel . |
Rel |
register(Rel rel,
Rel equivRel)
Registers a relational expression in the expression bank. |
private RelSubset |
registerImpl(Rel rel,
RelSet set)
Register a new expression exp . |
void |
registerSchema(Schema schema)
Tells this planner that a schema exists. |
private RelSubset |
registerSubset(RelSet set,
RelSubset subset)
|
(package private) void |
rename(Rel rel)
|
(package private) void |
reregister(RelSet set,
Rel rel)
|
void |
setRoot(Rel rel)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
HashMap mapRel2Subset
Rel
) to its
equivalence set (RelSubset
).
HashMap mapDigestToRel
digest
to the unique
relational expression
with that digest.
ArrayList allOperands
ArrayList allSets
private int nextSetId
HashSet registeredSchemas
private int registerCount
private final Graph conversionGraph
private final MultiMap mapArcToConverterRule
Graph.Arc
to a collection of
ConverterRule
.
protected RelSubset root
RuleQueue ruleQueue
private final ArrayList callingConventions
private final HashMap mapDescToRule
Constructor Detail |
VolcanoPlanner()
VolcanoPlanner
. You must now call init()
.
Method Detail |
public void setRoot(Rel rel)
setRoot
in interface Planner
public Rel getRoot()
getRoot
in interface Planner
public Planner chooseDelegate()
Planner
chooseDelegate
in interface Planner
public void addRule(Rule rule)
Planner
addRule
in interface Planner
void init()
public void addCallingConvention(CallingConvention convention)
Planner
addCallingConvention
in interface Planner
public Cost makeCost(double dRows, double dCpu, double dIo)
Planner
makeCost
in interface Planner
public Cost makeInfiniteCost()
Planner
makeInfiniteCost
in interface Planner
public Cost makeHugeCost()
Planner
makeHugeCost
in interface Planner
public Cost makeZeroCost()
Planner
makeZeroCost
in interface Planner
public Cost makeTinyCost()
Planner
makeTinyCost
in interface Planner
public Rel changeConvention(Rel rel, CallingConvention toConvention)
Planner
changeConvention
in interface Planner
private void fireRules(Rel rel, boolean deferred)
rel
- Relational expression which has just been created (or
maybe from the queue)deferred
- If true, each time a rule matches, just add an entry to
the queue.private void fireRulesForSubset(RelSubset childSubset)
Rel changeConventionUsingConverters(Rel rel, CallingConvention toConvention)
private Rel changeConvention(Rel rel, Graph.Arc arc)
public Rel findBestExp()
Planner
findBestExp
in interface Planner
void dump()
private RelSubset findBestPlan_old(RelSubset subset, Cost targetCost)
private RelSubset canonize(RelSubset subset)
private boolean fixupInputs(Rel rel)
private Cost optimize(Rel rel, Cost targetCost)
rel
. The cost is bounded by
targetCost
.
Cost getCost(Rel rel)
optimize(saffron.rel.Rel, saffron.opt.Cost)
, but does not
create any expressions.
public void registerSchema(Schema schema)
Planner
registerSchema
in interface Planner
public Rel register(Rel rel, Rel equivRel)
Planner
register
in interface Planner
rel
- Relational expression to registerequivRel
- Relational expression it is equivalent to (may be null)
private RelSubset registerImpl(Rel rel, RelSet set)
exp
. If set
is not
null, make the expression part of that equivalence set. If an identical
expression is already registered, we don't need to register this one.
rel
- relational expression to registerset
- set that rel belongs to, or null
void checkForSatisfiedConverters(RelSet set, Rel rel)
private RelSubset registerSubset(RelSet set, RelSubset subset)
private void merge(RelSet set, RelSet set2)
void reregister(RelSet set, Rel rel)
public RelSet getSet(Rel rel)
RelSubset getSubset(Rel rel)
RelSubset getSubset(Rel rel, CallingConvention convention)
void rename(Rel rel)
public Operand[] getConversionOperands(CallingConvention toConvention)
public boolean isRegistered(Rel rel)
public boolean canConvert(CallingConvention fromConvention, CallingConvention toConvention)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |