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 Stringprotected Collection<Object> Candidates objects to evaluate.protected ClassLoaderResolverprotected QueryCompilationCompilation of the underlying query, that we are evaluating.protected InMemoryExpressionEvaluatorThe evaluator.protected final Stringprotected MapMap of input parameter values, keyed by the parameter name.protected QueryUnderlying "string-based" query.static final StringName 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 BooleanConvenience 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 booleanChecks 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
-
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
-
satisfiesHavingClause
Checks if the results set fulfils the having clause.- Parameters:
set- Set of results- Returns:
- true if fulfilling having clause
-
handleResult
-
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
-