public class IndexQueryEngine extends ScanningQueryEngine
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 QueryIndexProvider instances.
| Modifier and Type | Class and Description |
|---|---|
static class |
IndexQueryEngine.Builder |
ScanningQueryEngine.DynamicOperandFilter, ScanningQueryEngine.PropertyValueExtractor, ScanningQueryEngine.ResultColumns, ScanningQueryEngine.RowFilterSupplier| 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 |
optimizer, planner, PSEUDO_COLUMN_NAMES, repositoryName| Modifier | Constructor and Description |
|---|---|
protected |
IndexQueryEngine(ExecutionContext context,
String repositoryName,
Planner planner,
Optimizer optimizer,
Map<String,QueryIndexProvider> indexProvidersByName) |
| 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
|
QueryContext |
createQueryContext(ExecutionContext context,
RepositoryCache repositoryCache,
Set<String> workspaceNames,
Map<String,NodeCache> overriddenNodeCachesByWorkspaceName,
Schemata schemata,
NodeTypes nodeTypes,
BufferManager bufferManager,
PlanHints hints,
Map<String,Object> variables)
Create a new context for query execution.
|
QueryIndexWriter |
getQueryIndexWriter()
Get the interface for updating the indexes.
|
void |
shutdown()
Signal that the engine is no longer needed and should clean up and/or close any resources.
|
createExtractFromRow, createExtractFromRow, createExtractReferencesFromRow, createNodeSequence, createNodeSequenceForSource, createRowFilter, createSortingExtractor, createSortingExtractor, determineProjectedColumns, determineType, execute, executeOptimizedQuery, literalValue, literalValues, toRegularExpression, toWildcardExpressionprotected static final Logger LOGGER
protected static final boolean TRACE
protected static final boolean DEBUG
protected IndexQueryEngine(ExecutionContext context, String repositoryName, Planner planner, Optimizer optimizer, Map<String,QueryIndexProvider> indexProvidersByName)
public static IndexQueryEngine.Builder builder()
public void shutdown()
QueryEngineshutdown in interface QueryEngineshutdown in class ScanningQueryEnginepublic QueryContext createQueryContext(ExecutionContext context, RepositoryCache repositoryCache, Set<String> workspaceNames, Map<String,NodeCache> overriddenNodeCachesByWorkspaceName, Schemata schemata, NodeTypes nodeTypes, BufferManager bufferManager, PlanHints hints, Map<String,Object> variables)
QueryEnginecreateQueryContext in interface QueryEnginecreateQueryContext in class ScanningQueryEnginecontext - the context in which the query is being executed; may not be nullrepositoryCache - the repository cache that should be used to load results; may be null if no results are to be loadedworkspaceNames - the name of each workspace to be queried, or an empty set if all the workspaces should be queried;
may not be nulloverriddenNodeCachesByWorkspaceName - the NodeCache instances that should be used to load results, which will be used
instead of the RepositoryCache's NodeCache for a given workspace name; may be null or emptyschemata - the schematanodeTypes - the snapshot of node types; may not be nullbufferManager - the buffer manager; may not be nullhints - the hints, or null if there are no hintsvariables - the mapping of variables and values, or null if there are no such variablespublic QueryIndexWriter getQueryIndexWriter()
QueryEnginegetQueryIndexWriter in interface QueryEnginegetQueryIndexWriter in class ScanningQueryEngineprotected NodeSequence createNodeSequenceForSource(QueryCommand originalQuery, QueryContext context, PlanNode sourceNode, IndexPlan indexPlan, QueryResults.Columns columns, QuerySources sources)
ScanningQueryEnginecreateNodeSequenceForSource in class ScanningQueryEngineoriginalQuery - the original query command; may not be nullcontext - the context in which the query is to be executed; may not be nullsourceNode - the PlanNode.Type.SOURCE plan node for one part of a query; may not be nullindexPlan - the IndexPlan specification; may not be nullcolumns - the result column definition; may not be nullsources - the query sources for the repository; may not be nullCopyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.