org.modeshape.jcr.query.engine

## Class IndexQueryEngine

- java.lang.Object
- - org.modeshape.jcr.query.engine.ScanningQueryEngine
  - - org.modeshape.jcr.query.engine.IndexQueryEngine

- All Implemented Interfaces:
    QueryEngine

      public class IndexQueryEngine
      extends ScanningQueryEngine

  A `QueryEngine` implementation that uses available indexes to more quickly produce query results.

  This query engine is capable of producing results for a query by scanning all nodes in the workspace(s) and filtering out any node that does not satisfy the criteria. This scanning is not very efficient and can result in slow queries, especially when the repository is quite large or when the number of nodes that satisfies the query's criteria is a small fraction of all possible nodes in the workspace(s).

  This engine can use indexes for certain properties so that it can more quickly identify the nodes that have property values satisfying the constraints of a query. It is possible to index all properties, but this requires significant space and evaluating all constraints using indexes may actually not be the most efficient and fastest approach. This query engine attempts to use a minimum number of indexes that will most quickly produce the set of nodes closest to the actual expected results.

  Indexes are access from the repository's `IndexProvider` instances.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `IndexQueryEngine.Builder`
    `protected static class` | `IndexQueryEngine.ProviderIndexPlanner` A `IndexPlanner` implementation that passes through only those indexes that are owned by the named provider.

    - ### Nested classes/interfaces inherited from class org.modeshape.jcr.query.engine.ScanningQueryEngine

      `ScanningQueryEngine.DynamicOperandFilter, ScanningQueryEngine.PropertyValueExtractor, ScanningQueryEngine.ResultColumns, ScanningQueryEngine.RowFilterSupplier`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static boolean` | `DEBUG`
    `protected static Logger` | `LOGGER` We don't use the standard logging convention here; we want clients to easily configure logging for the indexes
    `protected static boolean` | `TRACE`

    - ### Fields inherited from class org.modeshape.jcr.query.engine.ScanningQueryEngine

      `optimizer, planner, repositoryName`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `IndexQueryEngine(ExecutionContext context, String repositoryName, Planner planner, Optimizer optimizer, IndexManager indexManager)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static IndexQueryEngine.Builder` | `builder()` Obtain a builder that can be used to create new query engine instances.
    `protected NodeSequence` | `createNodeSequenceForSource(QueryCommand originalQuery, QueryContext context, PlanNode sourceNode, IndexPlan indexPlan, QueryResults.Columns columns, QuerySources sources)` Create a node sequence for the given index

    - ### Methods inherited from class org.modeshape.jcr.query.engine.ScanningQueryEngine

      `checkUnionCompatible, createExtractFromRow, createExtractFromRow, createExtractReferencesFromRow, createNodeSequence, createNodeSequenceForSource, createQueryContext, createRowFilter, createSortingExtractor, createSortingExtractor, determineProjectedColumns, determineType, execute, executeOptimizedQuery, literalValue, literalValues, shutdown, toRegularExpression, toWildcardExpression`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LOGGER

          protected static final Logger LOGGER

      We don't use the standard logging convention here; we want clients to easily configure logging for the indexes

    - #### TRACE

          protected static final boolean TRACE

    - #### DEBUG

          protected static final boolean DEBUG

  - ### Constructor Detail

    - #### IndexQueryEngine

          protected IndexQueryEngine(ExecutionContext context,
                          String repositoryName,
                          Planner planner,
                          Optimizer optimizer,
                          IndexManager indexManager)

  - ### Method Detail

    - #### builder

          public static IndexQueryEngine.Builder builder()

      Obtain a builder that can be used to create new query engine instances.
      Returns:
        the builder; never null

    - #### createNodeSequenceForSource

          protected NodeSequence createNodeSequenceForSource(QueryCommand originalQuery,
                                                 QueryContext context,
                                                 PlanNode sourceNode,
                                                 IndexPlan indexPlan,
                                                 QueryResults.Columns columns,
                                                 QuerySources sources)

      Description copied from class: `ScanningQueryEngine`
      Create a node sequence for the given index
      Overrides:
        `createNodeSequenceForSource` in class `ScanningQueryEngine`
      Parameters:
        `originalQuery` - the original query command; may not be null
        `context` - the context in which the query is to be executed; may not be null
        `sourceNode` - the `PlanNode.Type.SOURCE` plan node for one part of a query; may not be null
        `indexPlan` - the `IndexPlan` specification; may not be null
        `columns` - the result column definition; may not be null
        `sources` - the query sources for the repository; may not be null
      Returns:
        the sequence of results; null only if the type of index is not understood

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