Package org.infinispan.query.dsl.impl
Class BaseQuery<T>
java.lang.Object
org.infinispan.query.dsl.impl.BaseQuery<T>
- All Implemented Interfaces:
Iterable<T>,PaginationContext<Query<T>>,ParameterContext<Query<T>>,Query<T>
- Since:
- 7.2
- Author:
- anistor@redhat.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Integerprotected booleanprotected intprotected final String[]protected final QueryFactoryprotected final Stringprotected intprotected longOptional timeout in nanoseconds. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseQuery(QueryFactory queryFactory, String queryString) protectedBaseQuery(QueryFactory queryFactory, String queryString, Map<String, Object> namedParameters, String[] projection, long startOffset, int maxResults, boolean local) -
Method Summary
Modifier and TypeMethodDescriptionReturns aCloseableIteratorover the results, including both key and value.intExecutes a data modifying statement (typically a DELETE) that does not return results; instead it returns an affected entries count.intReturns the named parameters Map.String[]Returns the Ickle query string.longbooleanIndicates if the parsed query has projections (a SELECT clause) and consequently the returned results will actually beObject[]containing the projected values rather than the target entity.hitCountAccuracy(int hitCountAccuracy) Limit the required accuracy of the hit count for the indexed queries to an upper-bound.booleanisLocal()local(boolean local) Set the query execution scopemaxResults(int maxResults) abstract voidReset internal state after pagination or query parameters are modified.setParameter(String paramName, Object paramValue) Sets the value of a named parameter.setParameters(Map<String, Object> paramValues) Sets multiple named parameters at once.startOffset(long startOffset) Set the timeout for this query.voidEnsure all named parameters have non-null values.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.infinispan.query.dsl.Query
execute, getResultSize, iterator, list
-
Field Details
-
queryFactory
-
queryString
-
namedParameters
-
projection
-
startOffset
protected int startOffset -
maxResults
protected int maxResults -
hitCountAccuracy
-
local
protected boolean local -
timeout
protected long timeoutOptional timeout in nanoseconds.
-
-
Constructor Details
-
BaseQuery
-
BaseQuery
-
-
Method Details
-
getQueryString
Returns the Ickle query string.- Specified by:
getQueryStringin interfaceQuery<T>- Returns:
- the Ickle query string
-
getParameters
Description copied from interface:QueryReturns the named parameters Map.- Specified by:
getParametersin interfaceParameterContext<T>- Specified by:
getParametersin interfaceQuery<T>- Returns:
- the named parameters (unmodifiable) or
nullif the query does not have parameters
-
setParameter
Description copied from interface:QuerySets the value of a named parameter.- Specified by:
setParameterin interfaceParameterContext<T>- Specified by:
setParameterin interfaceQuery<T>- Parameters:
paramName- the parameters name (non-empty and not null)paramValue- a non-null value- Returns:
- itself
-
setParameters
Description copied from interface:QuerySets multiple named parameters at once. Parameters names cannot be empty ornull. Parameter values must not benull.- Specified by:
setParametersin interfaceParameterContext<T>- Specified by:
setParametersin interfaceQuery<T>- Parameters:
paramValues- a Map of parameters- Returns:
- itself
-
resetQuery
public abstract void resetQuery()Reset internal state after pagination or query parameters are modified. This is needed to ensure the next execution of the query uses the new values. -
validateNamedParameters
public void validateNamedParameters()Ensure all named parameters have non-null values. -
getProjection
- Specified by:
getProjectionin interfaceQuery<T>- Returns:
- the values for query projections or
nullif the query does not have projections.
-
hasProjections
public boolean hasProjections()Description copied from interface:QueryIndicates if the parsed query has projections (a SELECT clause) and consequently the returned results will actually beObject[]containing the projected values rather than the target entity.- Specified by:
hasProjectionsin interfaceQuery<T>- Returns:
trueif it has projections,falseotherwise.
-
getStartOffset
public long getStartOffset()- Specified by:
getStartOffsetin interfaceQuery<T>
-
getMaxResults
public int getMaxResults()- Specified by:
getMaxResultsin interfaceQuery<T>
-
startOffset
- Specified by:
startOffsetin interfacePaginationContext<T>- Specified by:
startOffsetin interfaceQuery<T>
-
maxResults
- Specified by:
maxResultsin interfacePaginationContext<T>- Specified by:
maxResultsin interfaceQuery<T>
-
hitCountAccuracy
- Specified by:
hitCountAccuracyin interfaceQuery<T>- Returns:
- current hitCountAccuracy if present
- See Also:
-
hitCountAccuracy
Description copied from interface:QueryLimit the required accuracy of the hit count for the indexed queries to an upper-bound. Setting the hit-count-accuracy could improve the performance of queries targeting large data sets.- Specified by:
hitCountAccuracyin interfaceQuery<T>- Parameters:
hitCountAccuracy- The value to apply- Returns:
this, for method chaining
-
local
Description copied from interface:QuerySet the query execution scope -
isLocal
public boolean isLocal() -
timeout
Description copied from interface:QuerySet the timeout for this query. If the query hasn't finished processing before the timeout, aSearchTimeoutExceptionwill be thrown. For queries that use the index, the timeout is handled on a best effort basis, and the supplied time is rounded to the nearest millisecond. -
entryIterator
Description copied from interface:QueryReturns aCloseableIteratorover the results, including both key and value. Please close the iterator when you are done with processing the results. The query cannot use projections.- Specified by:
entryIteratorin interfaceQuery<T>- Returns:
- the results of the query as an iterator.
-
executeStatement
public int executeStatement()Description copied from interface:QueryExecutes a data modifying statement (typically a DELETE) that does not return results; instead it returns an affected entries count. This method cannot be used to execute a SELECT.NOTE: Paging params (firstResult/maxResults) are NOT allowed.
- Specified by:
executeStatementin interfaceQuery<T>- Returns:
- the number of affected (deleted) entries
-