Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph.query.process
Class QueryProcessor

    java.lang.Object
      org.modeshape.graph.query.process.QueryProcessor

All Implemented Interfaces:
  Processor

    public abstract class QueryProcessor

extends Object
implements Processor

An abstract `Processor` implementation that builds a tree of `ProcessingComponent` objects to perform the different parts of the query processing logic. Subclasses are required to only implement one method: the `#createAccessComponent(QueryCommand,QueryContext, PlanNode, Columns, Analyzer)` should create a ProcessorComponent object that will perform the (low-level access) query described by the `plan` given as a parameter.

Constructor Summary
`QueryProcessor()`

Method Summary
`protected abstract ProcessingComponent` | `createAccessComponent(QueryCommand originalQuery, QueryContext context, PlanNode accessNode, QueryResults.Columns resultColumns, SelectComponent.Analyzer analyzer)` Create the `ProcessingComponent` that processes a single `PlanNode.Type.ACCESS` branch of a query plan.
`protected SelectComponent.Analyzer` | `createAnalyzer(QueryContext context)` Create an `SelectComponent.Analyzer` implementation that should be used by the non-access `ProcessingComponent`s that evaluate criteria.
`protected QueryResults.Columns` | `createColumnsFor(PlanNode node, QueryResults.Columns projectedColumns)`
`protected ProcessingComponent` | `createComponent(QueryCommand originalQuery, QueryContext context, PlanNode node, QueryResults.Columns columns, SelectComponent.Analyzer analyzer)` Method that is called to build up the `ProcessingComponent` objects that correspond to the optimized query plan.
`QueryResults` | `execute(QueryContext context, QueryCommand command, QueryResults.Statistics statistics, PlanNode plan)` Process the supplied query plan for the given command and return the results.
`protected void` | `postExecute(QueryContext context)` A method that can be overridden when a hook is required immediately after the top-level `ProcessingComponent` is executed and all processing has been completed, even if there was an error.
`protected void` | `preExecute(QueryContext context)` A method that can be overridden when a hook is required immediately before the top-level `ProcessingComponent` is executed.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### QueryProcessor

    public QueryProcessor()

Method Detail

### execute

    public QueryResults execute(QueryContext context,
                                QueryCommand command,
                                QueryResults.Statistics statistics,
                                PlanNode plan)

  Process the supplied query plan for the given command and return the results.

  Specified by:
    `execute` in interface `Processor`
  Parameters:
    `context` - the context in which the command is being processed
    `command` - the command being executed
    `statistics` - the time metrics up until this execution
    `plan` - the plan to be processed
  Returns:
    the results of the query
  See Also:
    `Processor.execute(org.modeshape.graph.query.QueryContext, org.modeshape.graph.query.model.QueryCommand, org.modeshape.graph.query.QueryResults.Statistics, org.modeshape.graph.query.plan.PlanNode)`

### preExecute

    protected void preExecute(QueryContext context)

  A method that can be overridden when a hook is required immediately before the top-level `ProcessingComponent` is executed. By default, this method does nothing.

  Parameters:
    `context` - the context in which the query is being executed; may not be null

### postExecute

    protected void postExecute(QueryContext context)

  A method that can be overridden when a hook is required immediately after the top-level `ProcessingComponent` is executed and all processing has been completed, even if there was an error. By default, this method does nothing.

  Parameters:
    `context` - the context in which the query is being executed; may not be null

### createAnalyzer

    protected SelectComponent.Analyzer createAnalyzer(QueryContext context)

  Create an `SelectComponent.Analyzer` implementation that should be used by the non-access `ProcessingComponent`s that evaluate criteria. By default, this method returns null, which means that any criteria evaluation will likely be pushed down under an `ACCESS` node (and thus handled by an `access component`.

  However, for more simple access components that are not capable of handling joins and other non-trivial criteria, simply return an Analyzer implementation that implements the methods using the source.

  Parameters:
    `context` - the context in which query is being evaluated
  Returns:
    the analyzer, or null if the ProcessingComponent objects that evaluate criteria should use a best-effort approach

### createAccessComponent

    protected abstract ProcessingComponent createAccessComponent(QueryCommand originalQuery,
                                                                 QueryContext context,
                                                                 PlanNode accessNode,
                                                                 QueryResults.Columns resultColumns,
                                                                 SelectComponent.Analyzer analyzer)

  Create the `ProcessingComponent` that processes a single `PlanNode.Type.ACCESS` branch of a query plan.

  Parameters:
    `originalQuery` - the original query that is being executed; never null
    `context` - the context in which query is being evaluated; never null
    `accessNode` - the node in the query plan that represents the `PlanNode.Type.ACCESS` plan; never null
    `resultColumns` - the columns that are to be returned; never null
    `analyzer` - the criteria analyzer; never null
  Returns:
    the processing component; may not be null

### createComponent

    protected ProcessingComponent createComponent(QueryCommand originalQuery,
                                                  QueryContext context,
                                                  PlanNode node,
                                                  QueryResults.Columns columns,
                                                  SelectComponent.Analyzer analyzer)

  Method that is called to build up the `ProcessingComponent` objects that correspond to the optimized query plan. This method is called by `#execute(QueryContext, QueryCommand, Statistics, PlanNode)` for each of the various `PlanNode` objects in the optimized query plan, and the method is actually recursive (since the optimized query plan forms a tree). However, whenever this call structure reaches the `ACCESS` nodes in the query plan (which each represents a separate atomic low-level query to the underlying system), the `#createAccessComponent(QueryCommand,QueryContext, PlanNode, Columns, Analyzer)` method is called. Subclasses should create an appropriate ProcessingComponent implementation that performs this atomic low-level query.

  Parameters:
    `originalQuery` - the original query that is being executed; never null
    `context` - the context in which query is being evaluated
    `node` - the plan node for which the ProcessingComponent is to be created
    `columns` - the definition of the result columns for this portion of the query
    `analyzer` - the analyzer (returned from `createAnalyzer(QueryContext)`) that should be used on the components that evaluate criteria; may be null if a best-effort should be made for the evaluation
  Returns:
    the processing component for this plan node; or null if there was an error recorded in the `problems`

### createColumnsFor

    protected QueryResults.Columns createColumnsFor(PlanNode node,
                                                    QueryResults.Columns projectedColumns)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.