org.modeshape.jcr.query.process

## Class QueryProcessor<ProcessingContextType>

- java.lang.Object
- - org.modeshape.jcr.query.process.QueryProcessor<ProcessingContextType>

- Type Parameters:
    `ProcessingContextType` - the processing context object type
  All Implemented Interfaces:
    Processor
  Direct Known Subclasses:
    LuceneQueryEngine.LuceneQueryProcessor

      public abstract class QueryProcessor<ProcessingContextType>
      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, Object)` should create a ProcessorComponent object that will perform the (low-level access) query described by the `plan` given as a parameter.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryProcessor()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `closeProcessingContext(ProcessingContextType processingContext)` A method that can be overridden to close the supplied processing context.
    `protected abstract ProcessingComponent` | `createAccessComponent(QueryCommand originalQuery, QueryContext context, PlanNode accessNode, QueryResults.Columns resultColumns, ProcessingContextType processingContext)` Create the `ProcessingComponent` that processes a single `PlanNode.Type.ACCESS` branch of a query plan.
    `protected QueryResults.Columns` | `createColumnsFor(PlanNode node, QueryResults.Columns projectedColumns)`
    `protected ProcessingComponent` | `createComponent(QueryCommand originalQuery, QueryContext context, PlanNode node, QueryResults.Columns columns, ProcessingContextType processingContext)` Method that is called to build up the `ProcessingComponent` objects that correspond to the optimized query plan.
    `protected ProcessingContextType` | `createProcessingContext(QueryContext queryContext)` A method that can be overridden by subclasses to create a single context object used for all the access queries for a single query.
    `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 abstract boolean` | `supportsPushDownExistConstraints()`

    - ### 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)

      Description copied from interface: `Processor`
      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

    - #### createProcessingContext

          protected ProcessingContextType createProcessingContext(QueryContext queryContext)

      A method that can be overridden by subclasses to create a single context object used for all the access queries for a single query.
      Parameters:
        `queryContext` - the context in which the query is being executed; never null
      Returns:
        the processing context object; may be null

    - #### closeProcessingContext

          protected void closeProcessingContext(ProcessingContextType processingContext)

      A method that can be overridden to close the supplied processing context. This method will always be called after a call to `createProcessingContext(QueryContext)`
      Parameters:
        `processingContext` - the processing context in which the query is being executed; null if `createProcessingContext(QueryContext)` returned null

    - #### supportsPushDownExistConstraints

          protected abstract boolean supportsPushDownExistConstraints()

    - #### createAccessComponent

          protected abstract ProcessingComponent createAccessComponent(QueryCommand originalQuery,
                                                  QueryContext context,
                                                  PlanNode accessNode,
                                                  QueryResults.Columns resultColumns,
                                                  ProcessingContextType processingContext)

      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
        `processingContext` - the processing context in which the query is being executed; null if `createProcessingContext(QueryContext)` returned null
      Returns:
        the processing component; may not be null

    - #### createComponent

          protected ProcessingComponent createComponent(QueryCommand originalQuery,
                                            QueryContext context,
                                            PlanNode node,
                                            QueryResults.Columns columns,
                                            ProcessingContextType processingContext)

      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, Object)` 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
        `processingContext` - the processing context in which the query is being executed; null if `createProcessingContext(QueryContext)` returned null
      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)

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