Interface Query<T>
- All Superinterfaces:
Iterable<T>
- All Known Subinterfaces:
Query<T>
- All Known Implementing Classes:
BaseQuery
- Since:
- 15.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault <K> ClosableIteratorWithCount<EntityEntry<K, T>> Returns aClosableIteratorWithCountover the results, including both key and value.<K> ClosableIteratorWithCount<EntityEntry<K, T>> entryIterator(boolean withMetadata) Returns aClosableIteratorWithCountover the results, including both key and value.execute()Executes the query (a SELECT statement).Reactive version ofexecute().intExecutes a data modifying statement (typically a DELETE) that does not return results; instead it returns the count of affected entries.Reactive version ofexecuteStatement()intReturns the maximum number of results configured for this query.Returns the named parameters Map.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.iterator()Returns aCloseableIteratorover the results.list()Returns the results of a search as a list.local(boolean local) Set the query execution scopemaxResults(int maxResults) Sets the maximum number of results to return.default org.reactivestreams.Publisher<T> publish(int maxBatchSize) Reactive based query forlist().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.Methods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
getQueryString
String getQueryString()Returns the Ickle query string. -
list
-
publish
Reactive based query forlist(). Will stream data as requested. The query will poll data from the underlying engine in batchSize blocks of items to satisfy the subscriptionIf
startOffset(long)ormaxResults(int)will affect the query by either not returning the first startOffset number of matches and will not return more than maxResults.Note: due to current API limitations it is not safe to use this Query instance while there is an active subscription to the returned Publisher and it is only safe to use one subscription at a time.
- Parameters:
maxBatchSize- the maximum amount of entries that will be retrieved at once. Note that a smaller batch size may be queried to ensure memory safety.- Returns:
- a Publisher that when subscribed will query
-
execute
QueryResult<T> execute()Executes the query (a SELECT statement). Subsequent invocations cause the query to be re-executed.Executing a DELETE is also allowed. In this case, no results will be returned, but the number of affected entries will be returned as the hit count in the
QueryResult.- Returns:
QueryResultwith the results.
-
executeAsync
Reactive version ofexecute().Note: due to current API limitations until this stage completes it is not safe to use this Query instance for any other invocations while there is an outstanding Publisher subscription or to have more than one subscription at a time.
- Returns:
- a Stage that when complete contains the query results
-
executeStatement
int executeStatement()Executes 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.
- Returns:
- the number of affected (deleted) entries
-
executeStatementAsync
Reactive version ofexecuteStatement()- Returns:
- a Stage that when complete contains the affected (deleted) entries
-
hasProjections
boolean hasProjections()Indicates 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.- Returns:
trueif it has projections,falseotherwise.
-
getStartOffset
long getStartOffset()Returns the start offset configured for this query.- Returns:
- the start offset
-
startOffset
Sets the starting offset into the overall result set. Must be equal or greater than 0. Use it in combination withmaxResults(int)to implement pagination.- Parameters:
startOffset- the start offset- Returns:
this, for method chaining
-
getMaxResults
int getMaxResults()Returns the maximum number of results configured for this query.- Returns:
- the maximum number of results
-
maxResults
Sets 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 withstartOffset(long)to implement pagination.- Parameters:
maxResults- the maximum number of results to return- Returns:
this, for method chaining
-
hitCountAccuracy
Integer hitCountAccuracy()- Returns:
- the current hitCountAccuracy if present
- See Also:
-
hitCountAccuracy
Limits 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.- Parameters:
hitCountAccuracy- The value to apply- Returns:
this, for method chaining
-
getParameters
-
setParameter
-
setParameters
-
iterator
CloseableIterator<T> iterator()Returns aCloseableIteratorover the results. Close the iterator when you are done with processing the results. -
entryIterator
Returns aClosableIteratorWithCountover the results, including both key and value. Close the iterator when you are done with processing the results. The query cannot use projections.- Returns:
- the results of the query as an iterator.
-
entryIterator
Returns aClosableIteratorWithCountover the results, including both key and value. Close the iterator when you are done with processing the results. The query cannot use projections.- Parameters:
withMetadata- Whether the cache entry metadata needs to be retrieved- Returns:
- the results of the query as an iterator.
-
timeout
Set 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. -
local
-
scoreRequired
-