Package org.datanucleus.store.query
Class QueryManagerImpl
- java.lang.Object
-
- org.datanucleus.store.query.QueryManagerImpl
-
- All Implemented Interfaces:
QueryManager
- Direct Known Subclasses:
FederatedQueryManagerImpl
public class QueryManagerImpl extends Object implements QueryManager
Manages the creation, compilation and results of queries. Provides caching of query compilations (generic and datastore-specific) and results.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,InvocationEvaluator>inmemoryQueryMethodEvaluatorByNameCache of InvocationEvaluator objects keyed by the "class:methodName", for use by in-memory querying.protected NucleusContextnucleusCtxprotected QueryCompilationCachequeryCompilationCacheCache for generic query compilations.protected QueryDatastoreCompilationCachequeryCompilationCacheDatastoreCache for datastore query compilations.protected Map<String,String>queryMethodAliasByPrefixprotected QueryResultsCachequeryResultsCacheCache for query results.protected StoreManagerstoreMgr
-
Constructor Summary
Constructors Constructor Description QueryManagerImpl(NucleusContext nucleusContext, StoreManager storeMgr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDatastoreQueryCompilation(String datastore, String language, String query, Object compilation)Method to store the datastore-specific compilation for a query.voidaddQueryCompilation(String language, String query, QueryCompilation compilation)Method to store the compilation for a query.voidaddQueryResult(Query query, Map params, List<Object> results)Method to store the results for a query.voidclose()Close the QueryManager, releasing all cached compilations and results.voidevictQueryResultsForType(Class cls)Method to evict all query results for the specified candidate type.ObjectgetDatastoreQueryCompilation(String datastore, String language, String query)Accessor for the datastore-specific compilation for a query.InvocationEvaluatorgetInMemoryEvaluatorForMethod(Class type, String methodName)Accessor for an evaluator for invocation of the specified method for the supplied type.QueryCompilationCachegetQueryCompilationCache()Accessor for the generic compilation cache.QueryCompilationgetQueryCompilationForQuery(String language, String query)Accessor for a Query compilation for the specified query and language.QueryDatastoreCompilationCachegetQueryDatastoreCompilationCache()Accessor for the datastore compilation cache.Map<String,String>getQueryMethodAliasesByPrefix()Accessor for JDOQL/JPQL query method aliases keyed by the prefix.List<Object>getQueryResult(Query query, Map params)Accessor for the results for a query.QueryResultsCachegetQueryResultsCache()Accessor for the query results cache.voidremoveDatastoreQueryCompilation(String datastore, String language, String query)Method to remove a cached datastore query compilation.voidremoveQueryCompilation(String language, String query)Method to remove a query compilation.
-
-
-
Field Detail
-
nucleusCtx
protected NucleusContext nucleusCtx
-
storeMgr
protected StoreManager storeMgr
-
queryCompilationCache
protected final QueryCompilationCache queryCompilationCache
Cache for generic query compilations.
-
queryCompilationCacheDatastore
protected final QueryDatastoreCompilationCache queryCompilationCacheDatastore
Cache for datastore query compilations.
-
queryResultsCache
protected final QueryResultsCache queryResultsCache
Cache for query results.
-
inmemoryQueryMethodEvaluatorByName
protected Map<String,InvocationEvaluator> inmemoryQueryMethodEvaluatorByName
Cache of InvocationEvaluator objects keyed by the "class:methodName", for use by in-memory querying.
-
-
Constructor Detail
-
QueryManagerImpl
public QueryManagerImpl(NucleusContext nucleusContext, StoreManager storeMgr)
-
-
Method Detail
-
close
public void close()
Description copied from interface:QueryManagerClose the QueryManager, releasing all cached compilations and results.- Specified by:
closein interfaceQueryManager
-
getQueryMethodAliasesByPrefix
public Map<String,String> getQueryMethodAliasesByPrefix()
Description copied from interface:QueryManagerAccessor for JDOQL/JPQL query method aliases keyed by the prefix.- Specified by:
getQueryMethodAliasesByPrefixin interfaceQueryManager- Returns:
- The method aliases map
-
getQueryCompilationCache
public QueryCompilationCache getQueryCompilationCache()
Description copied from interface:QueryManagerAccessor for the generic compilation cache.- Specified by:
getQueryCompilationCachein interfaceQueryManager- Returns:
- The cache of generic compilations
-
addQueryCompilation
public void addQueryCompilation(String language, String query, QueryCompilation compilation)
Description copied from interface:QueryManagerMethod to store the compilation for a query.- Specified by:
addQueryCompilationin interfaceQueryManager- Parameters:
language- Language of the queryquery- The query stringcompilation- The compilation of this query
-
removeQueryCompilation
public void removeQueryCompilation(String language, String query)
Description copied from interface:QueryManagerMethod to remove a query compilation.- Specified by:
removeQueryCompilationin interfaceQueryManager- Parameters:
language- The query languagequery- The query string
-
getQueryCompilationForQuery
public QueryCompilation getQueryCompilationForQuery(String language, String query)
Description copied from interface:QueryManagerAccessor for a Query compilation for the specified query and language.- Specified by:
getQueryCompilationForQueryin interfaceQueryManager- Parameters:
language- Language of the queryquery- Query string- Returns:
- The compilation (if present)
-
getQueryDatastoreCompilationCache
public QueryDatastoreCompilationCache getQueryDatastoreCompilationCache()
Description copied from interface:QueryManagerAccessor for the datastore compilation cache.- Specified by:
getQueryDatastoreCompilationCachein interfaceQueryManager- Returns:
- The cache of datastore compilations
-
addDatastoreQueryCompilation
public void addDatastoreQueryCompilation(String datastore, String language, String query, Object compilation)
Description copied from interface:QueryManagerMethod to store the datastore-specific compilation for a query.- Specified by:
addDatastoreQueryCompilationin interfaceQueryManager- Parameters:
datastore- The datastore identifierlanguage- The query languagequery- The query (string form)compilation- The compiled information
-
removeDatastoreQueryCompilation
public void removeDatastoreQueryCompilation(String datastore, String language, String query)
Description copied from interface:QueryManagerMethod to remove a cached datastore query compilation.- Specified by:
removeDatastoreQueryCompilationin interfaceQueryManager- Parameters:
datastore- The datastorelanguage- The languagequery- The query (string form)
-
getDatastoreQueryCompilation
public Object getDatastoreQueryCompilation(String datastore, String language, String query)
Description copied from interface:QueryManagerAccessor for the datastore-specific compilation for a query.- Specified by:
getDatastoreQueryCompilationin interfaceQueryManager- Parameters:
datastore- The datastore identifierlanguage- The query languagequery- The query (string form)- Returns:
- The compiled information (if available)
-
getQueryResultsCache
public QueryResultsCache getQueryResultsCache()
Description copied from interface:QueryManagerAccessor for the query results cache.- Specified by:
getQueryResultsCachein interfaceQueryManager- Returns:
- Query results cache (if present)
-
evictQueryResultsForType
public void evictQueryResultsForType(Class cls)
Description copied from interface:QueryManagerMethod to evict all query results for the specified candidate type.- Specified by:
evictQueryResultsForTypein interfaceQueryManager- Parameters:
cls- Candidate type
-
addQueryResult
public void addQueryResult(Query query, Map params, List<Object> results)
Description copied from interface:QueryManagerMethod to store the results for a query.- Specified by:
addQueryResultin interfaceQueryManager- Parameters:
query- The queryparams- Map of parameter values keyed by param nameresults- The results (List of object identities)
-
getQueryResult
public List<Object> getQueryResult(Query query, Map params)
Description copied from interface:QueryManagerAccessor for the results for a query.- Specified by:
getQueryResultin interfaceQueryManager- Parameters:
query- The queryparams- Map of parameter values keyed by param name- Returns:
- The results (List of object identities)
-
getInMemoryEvaluatorForMethod
public InvocationEvaluator getInMemoryEvaluatorForMethod(Class type, String methodName)
Description copied from interface:QueryManagerAccessor for an evaluator for invocation of the specified method for the supplied type. If it is not a supported method for that type then returns null.- Specified by:
getInMemoryEvaluatorForMethodin interfaceQueryManager- Parameters:
type- The class namemethodName- Name of the method- Returns:
- Evaluator suitable for this type with this method name
-
-