|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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 void |
allColumnsFor(Schemata.Table table,
SelectorName tableName,
List<Column> columns,
List<String> columnTypes)
|
protected PlanNode |
attachCriteria(QueryContext context,
PlanNode plan,
Constraint constraint,
List<? extends Column> columns,
Map<String,Subquery> subqueriesByVariableName)
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<? extends 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<? extends Ordering> orderings)
Attach SORT node at top of tree. |
protected PlanNode |
attachSubqueries(QueryContext context,
PlanNode plan,
Map<String,Subquery> subqueriesByVariableName)
Attach plan nodes for each subquery, resulting with the first subquery at the top of the plan 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 |
setSubqueryVariableName(PlanNode subqueryPlan,
String varName)
|
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, List<? extends Column> columns, Map<String,Subquery> subqueriesByVariableName)
context
- the context in which the query is being plannedplan
- the existing plan, which joins all source groupsconstraint
- the criteria or constraint from the querycolumns
- the columns in the select (that may have aliases)subqueriesByVariableName
- the subqueries by variable name
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<? extends 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<? extends 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 void allColumnsFor(Schemata.Table table, SelectorName tableName, List<Column> columns, List<String> columnTypes)
protected PlanNode attachDuplicateRemoval(QueryContext context, PlanNode plan)
context
- the context in which the query is being plannedplan
- the existing plan
protected PlanNode attachSubqueries(QueryContext context, PlanNode plan, Map<String,Subquery> subqueriesByVariableName)
context
- the context in which the query is being plannedplan
- the existing plansubqueriesByVariableName
- the queries by the variable name used in substitution
protected void setSubqueryVariableName(PlanNode subqueryPlan, String varName)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |