Class BaseQuery<T>
java.lang.Object
org.infinispan.commons.query.BaseQuery<T>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<K> ClosableIteratorWithCount<EntityEntry<K, T>> entryIterator(boolean withMetadata) Returns aClosableIteratorWithCountover the results, including both key and value.intExecutes a data modifying statement (typically a DELETE) that does not return results; instead it returns the count of affected entries.intReturns the maximum number of results configured for this query.Returns the named parameters Map.String[]Returns the Ickle query string.longReturns the start offset configured for this query.booleanIndicates 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) Limits 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) Sets the maximum number of results to return.abstract voidReset internal state after pagination or query parameters are modified.scoreRequired(boolean scoreRequired) 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) Sets the starting offset into the overall result set.Set the timeout for this query.voidEnsure all named parameters have non-null values.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface Query
entryIterator, executeStatementAsync, iterator, list, publishMethods inherited from interface Query
execute, executeAsync, getResultSize
-
Field Details
-
queryString
-
namedParameters
-
projection
-
startOffset
protected int startOffset -
maxResults
protected int maxResults -
hitCountAccuracy
-
local
protected boolean local -
scoreRequired
protected boolean scoreRequired -
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
-
setParameter
Description copied from interface:QuerySets the value of a named parameter.- Specified by:
setParameterin interfaceQuery<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. Parameter names cannot be empty ornull. Parameter values must not benull.- Specified by:
setParametersin interfaceQuery<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()Description copied from interface:QueryReturns the start offset configured for this query.- Specified by:
getStartOffsetin interfaceQuery<T>- Returns:
- the start offset
-
getMaxResults
public int getMaxResults()Description copied from interface:QueryReturns the maximum number of results configured for this query.- Specified by:
getMaxResultsin interfaceQuery<T>- Returns:
- the maximum number of results
-
startOffset
Description copied from interface:QuerySets the starting offset into the overall result set. Must be equal or greater than 0. Use it in combination withQuery.maxResults(int)to implement pagination.- Specified by:
startOffsetin interfaceQuery<T>- Specified by:
startOffsetin interfaceQuery<T>- Parameters:
startOffset- the start offset- Returns:
this, for method chaining
-
maxResults
Description copied from interface:QuerySets the maximum number of results to return. Must be equal or greater than 0. When 0 is set, the execution of the query will not return any results, but will still information about thetotal number of hits. Use it in combination withQuery.startOffset(long)to implement pagination.- Specified by:
maxResultsin interfaceQuery<T>- Specified by:
maxResultsin interfaceQuery<T>- Parameters:
maxResults- the maximum number of results to return- Returns:
this, for method chaining
-
hitCountAccuracy
- Specified by:
hitCountAccuracyin interfaceQuery<T>- Returns:
- the current hitCountAccuracy if present
- See Also:
-
hitCountAccuracy
Description copied from interface:QueryLimits 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>- Specified by:
hitCountAccuracyin interfaceQuery<T>- Parameters:
hitCountAccuracy- The value to apply- Returns:
this, for method chaining
-
local
-
isLocal
public boolean isLocal() -
scoreRequired
- Specified by:
scoreRequiredin interfaceQuery<T>
-
timeout
Description copied from interface:QuerySet the timeout for this query. If the query hasn't finished processing before the timeout, a timeout will 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 aClosableIteratorWithCountover the results, including both key and value. Close the iterator when you are done with processing the results. The query cannot use projections.- Specified by:
entryIteratorin interfaceQuery<T>- Parameters:
withMetadata- Whether the cache entry metadata needs to be retrieved- 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 the count of affected entries. This method cannot be used to execute a SELECT.NOTE: Paging parameters (firstResult/maxResults) are NOT allowed.
- Specified by:
executeStatementin interfaceQuery<T>- Returns:
- the number of affected (deleted) entries
-