Class QueryHelper
java.lang.Object
org.keycloak.models.sessions.infinispan.query.QueryHelper
-
Field Summary
Modifier and TypeFieldDescriptionConverts a single projection results into a long value.Converts a single projection value into aString
. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
R> Optional<R> fetchSingle
(org.infinispan.commons.api.query.Query<T> query, Function<T, R> mapping) Fetches a single value from the query.static <T,
R> Stream<R> Streams using batching over all results from theQuery
.static <T,
R> Collection<R> toCollection
(org.infinispan.commons.api.query.Query<T> query, Function<T, R> mapping) Performs theQuery
and returns the results.
-
Field Details
-
SINGLE_PROJECTION_TO_LONG
Converts a single projection results into a long value. -
SINGLE_PROJECTION_TO_STRING
Converts a single projection value into aString
. -
PROJECTION_TO_STRING_LONG_ENTRY
-
-
Method Details
-
fetchSingle
public static <T,R> Optional<R> fetchSingle(org.infinispan.commons.api.query.Query<T> query, Function<T, R> mapping) Fetches a single value from the query.This method changes the
Query
state to return just a single value. -
streamAll
public static <T,R> Stream<R> streamAll(org.infinispan.commons.api.query.Query<T> query, int batchSize, Function<T, R> mapping) Streams using batching over all results from theQuery
.If a large result set is expected, this method is recommended to avoid loading downloading a lot of data in a single request.
The results are fetched on demand.
Warning: This method changes ignores the start offset and the max results. It will return everything.
-
toCollection
public static <T,R> Collection<R> toCollection(org.infinispan.commons.api.query.Query<T> query, Function<T, R> mapping) Performs theQuery
and returns the results.This method is preferred to
Query.list()
since it does not have to compute an accurate hit count (affects Indexed query performance).If a large dataset is expected, use
streamAll(Query, int, Function)
.- Type Parameters:
T
- TheQuery
response type.R
- TheCollection
type.- Parameters:
query
- TheQuery
instance.mapping
- TheFunction
that maps the query results (projection) into the result.- Returns:
- A
Collection
with the results.
-