org.xcmis.search.query.plan
Class SimplePlaner

java.lang.Object
  extended by org.xcmis.search.query.plan.SimplePlaner
All Implemented Interfaces:
QueryExecutionPlaner

public class SimplePlaner
extends Object
implements QueryExecutionPlaner

The planner that produces a simple query plan given a query .

A simple plan always has the same structure:

       LIMIT       if row limit or offset are used
         |
      SORTING      if 'ORDER BY' is used with more then one Source
         |
      WHERE1
         |         One or more WHERE plan nodes that each have
      WHERE2      a single non-join constraint 
         |         
      WHEREn
         |
    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
SimplePlaner()
           
 
Method Summary
protected  QueryExecutionPlan createConstrainPlan(QueryExecutionContext context, org.xcmis.search.model.constraint.Constraint constraint, Map<org.xcmis.search.model.source.SelectorName,Schema.Table> querySelectorsMap, QueryExecutionPlan executionPlan)
           
protected  QueryExecutionPlan createLimits(QueryExecutionContext context, org.xcmis.search.model.Limit limit, QueryExecutionPlan executionPlan)
          Attach a LIMIT node at the top of the plan tree.
 QueryExecutionPlan createPlan(QueryExecutionContext context, org.xcmis.search.model.Query query)
          Create a canonical query plan for the given command.
protected  QueryExecutionPlan createProject(QueryExecutionContext context, List<org.xcmis.search.model.column.Column> columns, Map<org.xcmis.search.model.source.SelectorName,Schema.Table> selectors, QueryExecutionPlan executionPlan)
          Attach a PROJECT node at the top of the plan tree.
protected  QueryExecutionPlan createSelectorPlan(QueryExecutionContext context, org.xcmis.search.model.source.Source source, Map<org.xcmis.search.model.source.SelectorName,Schema.Table> querySelectorsMap)
          Populate plan for given selector.
protected  QueryExecutionPlan createSorting(QueryExecutionContext context, List<org.xcmis.search.model.ordering.Ordering> orderings, QueryExecutionPlan executionPlan)
          populate SORT node at top of executionPlan.
protected  void separateAndConstraints(org.xcmis.search.model.constraint.Constraint constraint, List<org.xcmis.search.model.constraint.Constraint> andableConstraints)
          Walk the supplied constraint to extract a list of the constraints that can be AND-ed together.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimplePlaner

public SimplePlaner()
Method Detail

createPlan

public QueryExecutionPlan createPlan(QueryExecutionContext context,
                                     org.xcmis.search.model.Query query)
Description copied from interface: QueryExecutionPlaner
Create a canonical query plan for the given command.

Specified by:
createPlan in interface QueryExecutionPlaner
Parameters:
context - the context in which the query is being planned
query - the query command to be planned
Returns:
the root node of the plan tree representing the canonical plan
See Also:
QueryExecutionPlaner.createPlan(org.xcmis.search.query.QueryExecutionContext, org.xcmis.search.model.Query)

createConstrainPlan

protected QueryExecutionPlan createConstrainPlan(QueryExecutionContext context,
                                                 org.xcmis.search.model.constraint.Constraint constraint,
                                                 Map<org.xcmis.search.model.source.SelectorName,Schema.Table> querySelectorsMap,
                                                 QueryExecutionPlan executionPlan)
Parameters:
context -
constraint -
querySelectorsMap -
executionPlan -
Returns:

createSelectorPlan

protected QueryExecutionPlan createSelectorPlan(QueryExecutionContext context,
                                                org.xcmis.search.model.source.Source source,
                                                Map<org.xcmis.search.model.source.SelectorName,Schema.Table> querySelectorsMap)
                                         throws org.xcmis.search.VisitException
Populate plan for given selector.

Parameters:
context -
source -
querySelectorsMap -
Returns:
QueryExecutionPlan
Throws:
org.xcmis.search.VisitException

createSorting

protected QueryExecutionPlan createSorting(QueryExecutionContext context,
                                           List<org.xcmis.search.model.ordering.Ordering> orderings,
                                           QueryExecutionPlan executionPlan)
populate SORT node at top of executionPlan. The SORT may be pushed down to a source (or sources) if possible by the optimizer.

Parameters:
context - the context in which the query is being planned
orderings - list of orderings from the query
executionPlan - the existing plan

createProject

protected QueryExecutionPlan createProject(QueryExecutionContext context,
                                           List<org.xcmis.search.model.column.Column> columns,
                                           Map<org.xcmis.search.model.source.SelectorName,Schema.Table> selectors,
                                           QueryExecutionPlan executionPlan)
Attach a PROJECT node at the top of the plan tree.

Parameters:
context - the context in which the query is being planned
executionPlan - the existing plan
columns - the columns being projected; may be null
selectors - the selectors keyed by their alias or name
Returns:
the updated plan

createLimits

protected QueryExecutionPlan createLimits(QueryExecutionContext context,
                                          org.xcmis.search.model.Limit limit,
                                          QueryExecutionPlan executionPlan)
Attach a LIMIT node at the top of the plan tree.

Parameters:
context - the context in which the query is being planned
limit - the limit definition; may be null
executionPlan - the existing plan *

separateAndConstraints

protected void separateAndConstraints(org.xcmis.search.model.constraint.Constraint constraint,
                                      List<org.xcmis.search.model.constraint.Constraint> andableConstraints)
Walk the supplied constraint to extract a list of the constraints that can be AND-ed together. For example, given the constraint tree ((C1 AND C2) AND (C3 OR C4)), this method would result in a list of three separate criteria: [C1,C2,(C3 OR C4)]. The resulting andConstraints list will contain Constraint objects that all must be true.

Parameters:
constraint - the input constraint
andableConstraints - the collection into which all non-AND constraints should be placed


Copyright © 2011 eXo Platform SAS. All Rights Reserved.