|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.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. |
protected boolean |
ambitious
If true, the planner keeps applying rules as long as they continue to reduce the cost. |
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 ( SaffronRel ) 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 | |
VolcanoPlanner()
Creates a uninitialized VolcanoPlanner . |
Method Summary | |
void |
addCallingConvention(CallingConvention convention)
Registers a calling convention. |
void |
addRule(VolcanoRule rule)
Registers a rule. |
boolean |
canConvert(CallingConvention fromConvention,
CallingConvention toConvention)
|
private RelSubset |
canonize(RelSubset subset)
|
SaffronRel |
changeConvention(SaffronRel rel,
CallingConvention toConvention)
Changes a relational expression to an equivalent one of a different calling convention. |
private SaffronRel |
changeConvention(SaffronRel rel,
Graph.Arc arc)
Tries to convert a relational expression to the target convention of an arc. |
(package private) SaffronRel |
changeConventionUsingConverters(SaffronRel rel,
CallingConvention toConvention)
|
(package private) void |
checkForSatisfiedConverters(RelSet set,
SaffronRel rel)
|
SaffronPlanner |
chooseDelegate()
Negotiates an appropriate planner to deal with distributed queries. |
(package private) void |
dump()
|
SaffronRel |
findBestExp()
Find the most efficient expression to implement this query. |
private RelSubset |
findBestPlan_old(RelSubset subset,
PlanCost targetCost)
|
private void |
fireRules(SaffronRel rel,
boolean deferred)
Fire all rules matched by a relational expression. |
private void |
fireRulesForSubset(RelSubset childSubset)
|
private boolean |
fixupInputs(SaffronRel rel)
|
RuleOperand[] |
getConversionOperands(CallingConvention toConvention)
|
(package private) PlanCost |
getCost(SaffronRel rel)
Finds the cost of a node. |
SaffronRel |
getRoot()
|
RelSet |
getSet(SaffronRel rel)
Find an expression's equivalence set. |
(package private) RelSubset |
getSubset(SaffronRel rel)
|
(package private) RelSubset |
getSubset(SaffronRel rel,
CallingConvention convention)
|
boolean |
isRegistered(SaffronRel rel)
|
PlanCost |
makeCost(double dRows,
double dCpu,
double dIo)
Create a cost object. |
PlanCost |
makeHugeCost()
Create a cost object representing an enormous non-infinite cost. |
PlanCost |
makeInfiniteCost()
Create a cost object representing infinite cost. |
PlanCost |
makeTinyCost()
Create a cost object representing a small positive cost. |
PlanCost |
makeZeroCost()
Create a cost object representing zero cost. |
private void |
merge(RelSet set,
RelSet set2)
|
private PlanCost |
optimize(SaffronRel rel,
PlanCost targetCost)
By optimizing its children, find the best implementation of relational expression rel . |
SaffronRel |
register(SaffronRel rel,
SaffronRel equivRel)
Registers a relational expression in the expression bank. |
void |
registerAbstractRelationalRules()
|
void |
registerAbstractRels()
|
private RelSubset |
registerImpl(SaffronRel rel,
RelSet set)
Register a new expression exp . |
void |
registerSchema(SaffronSchema schema)
Tells this planner that a schema exists. |
private RelSubset |
registerSubset(RelSet set,
RelSubset subset)
|
(package private) void |
rename(SaffronRel rel)
|
(package private) void |
reregister(RelSet set,
SaffronRel rel)
|
void |
setRoot(SaffronRel rel)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected RelSubset root
protected boolean ambitious
ArrayList allOperands
ArrayList allSets
HashMap mapDigestToRel
digest
to the unique relational expression
with that digest.
HashMap mapRel2Subset
SaffronRel
) to its equivalence
set (RelSubset
).
HashSet registeredSchemas
RuleQueue ruleQueue
private final ArrayList callingConventions
private final Graph conversionGraph
private final HashMap mapDescToRule
private final MultiMap mapArcToConverterRule
Graph.Arc
to a collection of
ConverterRule
objects.
private int nextSetId
private int registerCount
Constructor Detail |
public VolcanoPlanner()
VolcanoPlanner
. To fully
initialize it, the caller must register the desired set of relations,
rules, and calling conventions.
Method Detail |
public RuleOperand[] getConversionOperands(CallingConvention toConvention)
public boolean isRegistered(SaffronRel rel)
public void setRoot(SaffronRel rel)
setRoot
in interface SaffronPlanner
public SaffronRel getRoot()
getRoot
in interface SaffronPlanner
public RelSet getSet(SaffronRel rel)
public void addCallingConvention(CallingConvention convention)
SaffronPlanner
addCallingConvention
in interface SaffronPlanner
public void addRule(VolcanoRule rule)
SaffronPlanner
addRule
in interface SaffronPlanner
public boolean canConvert(CallingConvention fromConvention, CallingConvention toConvention)
public SaffronRel changeConvention(SaffronRel rel, CallingConvention toConvention)
SaffronPlanner
changeConvention
in interface SaffronPlanner
public SaffronPlanner chooseDelegate()
SaffronPlanner
chooseDelegate
in interface SaffronPlanner
public SaffronRel findBestExp()
SaffronPlanner
findBestExp
in interface SaffronPlanner
public PlanCost makeCost(double dRows, double dCpu, double dIo)
SaffronPlanner
makeCost
in interface SaffronPlanner
public PlanCost makeHugeCost()
SaffronPlanner
makeHugeCost
in interface SaffronPlanner
public PlanCost makeInfiniteCost()
SaffronPlanner
makeInfiniteCost
in interface SaffronPlanner
public PlanCost makeTinyCost()
SaffronPlanner
makeTinyCost
in interface SaffronPlanner
public PlanCost makeZeroCost()
SaffronPlanner
makeZeroCost
in interface SaffronPlanner
public SaffronRel register(SaffronRel rel, SaffronRel equivRel)
SaffronPlanner
register
in interface SaffronPlanner
rel
- Relational expression to registerequivRel
- Relational expression it is equivalent to (may be null)
public void registerAbstractRelationalRules()
public void registerAbstractRels()
public void registerSchema(SaffronSchema schema)
SaffronPlanner
registerSchema
in interface SaffronPlanner
PlanCost getCost(SaffronRel rel)
optimize(net.sf.saffron.rel.SaffronRel, net.sf.saffron.opt.PlanCost)
, but does not
create any expressions.
RelSubset getSubset(SaffronRel rel)
RelSubset getSubset(SaffronRel rel, CallingConvention convention)
SaffronRel changeConventionUsingConverters(SaffronRel rel, CallingConvention toConvention)
void checkForSatisfiedConverters(RelSet set, SaffronRel rel)
void dump()
void rename(SaffronRel rel)
void reregister(RelSet set, SaffronRel rel)
private RelSubset canonize(RelSubset subset)
private SaffronRel changeConvention(SaffronRel rel, Graph.Arc arc)
private RelSubset findBestPlan_old(RelSubset subset, PlanCost targetCost)
private void fireRules(SaffronRel 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)
private boolean fixupInputs(SaffronRel rel)
private void merge(RelSet set, RelSet set2)
private PlanCost optimize(SaffronRel rel, PlanCost targetCost)
rel
. The cost is bounded by
targetCost
.
private RelSubset registerImpl(SaffronRel 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
private RelSubset registerSubset(RelSet set, RelSubset subset)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |