Class JavaQueryInMemoryEvaluator
java.lang.Object
org.datanucleus.store.query.inmemory.JavaQueryInMemoryEvaluator
- Direct Known Subclasses:
JDOQLInMemoryEvaluator
,JPQLInMemoryEvaluator
Class to evaluate a Java "string-based" query in whole or part.
Takes in the "generic" compilation, a list of instances and applies the required restrictions to the input giving a final result.
Typically extended for JDOQL, JPQL specifics.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
protected Collection
<Object> Candidates objects to evaluate.protected ClassLoaderResolver
protected QueryCompilation
Compilation of the underlying query, that we are evaluating.protected InMemoryExpressionEvaluator
The evaluator.protected final String
protected Map
Map of input parameter values, keyed by the parameter name.protected Query
Underlying "string-based" query.static final String
Name under which any set of results are stored in the state map.Map of state symbols for the query evaluation. -
Constructor Summary
ConstructorsConstructorDescriptionJavaQueryInMemoryEvaluator
(String language, Query query, QueryCompilation compilation, Map<Object, Object> parameterValues, ClassLoaderResolver clr, Collection<Object> candidates) Constructor for the evaluator of a query in the specified language. -
Method Summary
Modifier and TypeMethodDescriptionprivate Boolean
Convenience method to evaluate the provided expression returning a boolean.protected abstract Collection
<Object> evaluateSubquery
(Query subquery, QueryCompilation compilation, Collection<Object> candidates, Object outerCandidate) Method to evaluate a subquery of the query being evaluated.execute
(boolean applyFilter, boolean applyOrdering, boolean applyResult, boolean applyResultClass, boolean applyRange) Method to perform the evaluation, applying the query restrictions that are required.handleAggregates
(List<Object> resultSet) Checks if there are aggregates and handle it.handleFilter
(List<Object> set) handleRange
(List<Object> set, long fromIncl, long toExcl) handleResult
(List<Object> resultSet) Checks if there are aggregates and handles it.(package private) abstract Collection
<Object> mapResultClass
(Collection<Object> resultSet) Constructs ResultClassMapper and calls its map functionprivate Object[]
private Object[]
private boolean
Checks if the results set fulfils the having clause.sortByGrouping
(List<Object> set)
-
Field Details
-
RESULTS_SET
Name under which any set of results are stored in the state map. Used for aggregation.- See Also:
-
language
-
candidateAlias
-
candidates
Candidates objects to evaluate. -
query
Underlying "string-based" query. -
compilation
Compilation of the underlying query, that we are evaluating. -
parameterValues
Map of input parameter values, keyed by the parameter name. -
evaluator
The evaluator. -
state
Map of state symbols for the query evaluation. -
clr
-
-
Constructor Details
-
JavaQueryInMemoryEvaluator
public JavaQueryInMemoryEvaluator(String language, Query query, QueryCompilation compilation, Map<Object, Object> parameterValues, ClassLoaderResolver clr, Collection<Object> candidates) Constructor for the evaluator of a query in the specified language.- Parameters:
language
- Name of the languagequery
- The underlying querycompilation
- Query compilationparameterValues
- Input parameter valuesclr
- ClassLoader resolvercandidates
- Candidate objects
-
-
Method Details
-
evaluateSubquery
protected abstract Collection<Object> evaluateSubquery(Query subquery, QueryCompilation compilation, Collection<Object> candidates, Object outerCandidate) Method to evaluate a subquery of the query being evaluated.- Parameters:
subquery
- The subquerycompilation
- The subquery compilationcandidates
- The candidates for the subqueryouterCandidate
- The current outer candidate (for use when linking back to outer query)- Returns:
- The result
-
execute
public Collection<Object> execute(boolean applyFilter, boolean applyOrdering, boolean applyResult, boolean applyResultClass, boolean applyRange) Method to perform the evaluation, applying the query restrictions that are required.- Parameters:
applyFilter
- Whether to apply any filter constraints on the resultsapplyOrdering
- Whether to apply any order constraints on the resultsapplyResult
- Whether to apply any result/grouping/having on the resultsapplyResultClass
- Whether to apply any resultClass constraint on the resultsapplyRange
- Whether to apply any range constraint on the results- Returns:
- The results after evaluation.
-
handleFilter
-
evaluateBooleanExpression
Convenience method to evaluate the provided expression returning a boolean. Caters for variables in the provided expression, attempting to process all possible values for them.- Parameters:
expr
- The expressioneval
- The evaluator- Returns:
- The result
-
handleRange
-
sortByGrouping
-
ordering
-
handleAggregates
Checks if there are aggregates and handle it.- Parameters:
resultSet
- The resultSet containing all elements- Returns:
- A list with aggregated elements
-
satisfiesHavingClause
Checks if the results set fulfils the having clause.- Parameters:
set
- Set of results- Returns:
- true if fulfilling having clause
-
handleResult
Checks if there are aggregates and handles it.- Parameters:
resultSet
- The resultSet containing all elements- Returns:
- A list with aggregated elements
-
result
-
result
-
mapResultClass
Constructs ResultClassMapper and calls its map function- Parameters:
resultSet
- The resultSet containing the instances handled by setResult- Returns:
- The resultSet containing instances of the Class defined by setResultClass
-