|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.modeshape.graph.query.plan.CanonicalPlanner
public class CanonicalPlanner
The planner that produces a canonical query plan given a query command
.
A canonical plan always has the same structure:
LIMIT if row limit or offset are used
|
SORTING if 'ORDER BY' is used
|
DUP_REMOVE if 'SELECT DISTINCT' is used
|
PROJECT with the list of columns being SELECTed
|
GROUP if 'GROUP BY' is used
|
SELECT1
| One or more SELECT plan nodes that each have
SELECT2 a single non-join constraint that are then all AND-ed
| together (see separateAndConstraints(Constraint, List)
)
SELECTn
|
SOURCE or JOIN A single SOURCE or JOIN node, depending upon the query
/ \
/ \
SOJ SOJ A SOURCE or JOIN node for the left and right side of the JOIN
There leaves of the tree are always SOURCE nodes, so conceptually data always flows through this plan from the bottom SOURCE nodes, is adjusted/filtered as it trickles up through the plan, and is then ready to be used by the caller as it emerges from the top node of the plan.
This canonical plan, however, is later optimized and rearranged so that it performs faster.
Constructor Summary | |
---|---|
CanonicalPlanner()
|
Method Summary | |
---|---|
protected PlanNode |
attachCriteria(QueryContext context,
PlanNode plan,
Constraint constraint)
Attach all criteria above the join nodes. |
protected PlanNode |
attachDuplicateRemoval(QueryContext context,
PlanNode plan)
Attach DUP_REMOVE node at top of tree. |
protected PlanNode |
attachLimits(QueryContext context,
PlanNode plan,
Limit limit)
Attach a LIMIT node at the top of the plan tree. |
protected PlanNode |
attachProject(QueryContext context,
PlanNode plan,
List<Column> columns,
Map<SelectorName,Schemata.Table> selectors)
Attach a PROJECT node at the top of the plan tree. |
protected PlanNode |
attachSorting(QueryContext context,
PlanNode plan,
List<Ordering> orderings)
Attach SORT node at top of tree. |
protected PlanNode |
createCanonicalPlan(QueryContext context,
Query query)
Create a canonical query plan for the given query. |
protected PlanNode |
createCanonicalPlan(QueryContext context,
SetQuery query)
Create a canonical query plan for the given set query. |
PlanNode |
createPlan(QueryContext context,
QueryCommand query)
Create a canonical query plan for the given command. |
protected PlanNode |
createPlanNode(QueryContext context,
Source source,
Map<SelectorName,Schemata.Table> usedSelectors)
Create a JOIN or SOURCE node that contain the source information. |
protected void |
separateAndConstraints(Constraint constraint,
List<Constraint> andableConstraints)
Walk the supplied constraint to extract a list of the constraints that can be AND-ed together. |
protected void |
validate(QueryContext context,
QueryCommand query,
Map<SelectorName,Schemata.Table> usedSelectors)
Validate the supplied query. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CanonicalPlanner()
Method Detail |
---|
public PlanNode createPlan(QueryContext context, QueryCommand query)
createPlan
in interface Planner
context
- the context in which the query is being plannedquery
- the query command to be planned
Planner.createPlan(org.modeshape.graph.query.QueryContext,
org.modeshape.graph.query.model.QueryCommand)
protected PlanNode createCanonicalPlan(QueryContext context, Query query)
context
- the context in which the query is being plannedquery
- the query to be planned
protected void validate(QueryContext context, QueryCommand query, Map<SelectorName,Schemata.Table> usedSelectors)
context
- the context in which the query is being plannedquery
- the set query to be plannedusedSelectors
- the map of SelectorName
s (aliases or names) used in the query.protected PlanNode createCanonicalPlan(QueryContext context, SetQuery query)
context
- the context in which the query is being plannedquery
- the set query to be planned
protected PlanNode createPlanNode(QueryContext context, Source source, Map<SelectorName,Schemata.Table> usedSelectors)
context
- the execution contextsource
- the source to be processed; may not be nullusedSelectors
- the map of SelectorName
s (aliases or names) used in the query.
protected PlanNode attachCriteria(QueryContext context, PlanNode plan, Constraint constraint)
context
- the context in which the query is being plannedplan
- the existing plan, which joins all source groupsconstraint
- the criteria or constraint from the query
protected void separateAndConstraints(Constraint constraint, List<Constraint> andableConstraints)
andConstraints
list will contain Constraint objects that all must be true.
constraint
- the input constraintandableConstraints
- the collection into which all non-AND
constraints should be placedprotected PlanNode attachSorting(QueryContext context, PlanNode plan, List<Ordering> orderings)
context
- the context in which the query is being plannedplan
- the existing planorderings
- list of orderings from the query
protected PlanNode attachLimits(QueryContext context, PlanNode plan, Limit limit)
context
- the context in which the query is being plannedplan
- the existing planlimit
- the limit definition; may be null
protected PlanNode attachProject(QueryContext context, PlanNode plan, List<Column> columns, Map<SelectorName,Schemata.Table> selectors)
context
- the context in which the query is being plannedplan
- the existing plancolumns
- the columns being projected; may be nullselectors
- the selectors keyed by their alias or name
protected PlanNode attachDuplicateRemoval(QueryContext context, PlanNode plan)
context
- the context in which the query is being plannedplan
- the existing plan
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |