Class InternalQuery<T,Q extends InternalQuery<T,Q>>
- Direct Known Subclasses:
InternalAccountQuery
,InternalChangeQuery
,InternalGroupQuery
By default, visibility of returned entities is not enforced (unlike in QueryProcessor
). The methods in this class are not typically used by user-facing paths, but
rather by internal callers that need to process all matching results.
Instances are one-time-use. Other singleton classes should inject a Provider rather than holding on to a single instance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final IndexConfig
protected final IndexCollection<?,
T, ? extends Index<?, T>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
InternalQuery
(QueryProcessor<T> queryProcessor, IndexCollection<?, T, ? extends Index<?, T>> indexes, IndexConfig indexConfig) -
Method Summary
Modifier and TypeMethodDescriptionfinal Q
enforceVisibility
(boolean enforce) final Q
noFields()
final com.google.common.collect.ImmutableList<T>
Run multiple queries in parallel.protected static <T> com.google.common.collect.ImmutableList<T>
queryExhaustively
(Supplier<? extends InternalQuery<T, ?>> querySupplier, Predicate<T> predicate) Query a predicate repeatedly until all results are exhausted.schema()
protected final Q
self()
final Q
setLimit
(int n) final Q
setRequestedFields
(SchemaFieldDefs.SchemaField<T, ?>... fields)
-
Field Details
-
indexes
-
indexConfig
-
-
Constructor Details
-
InternalQuery
protected InternalQuery(QueryProcessor<T> queryProcessor, IndexCollection<?, T, ? extends Index<?, T>> indexes, IndexConfig indexConfig)
-
-
Method Details
-
self
-
setLimit
-
enforceVisibility
-
setRequestedFields
-
noFields
-
query
-
query
Run multiple queries in parallel.If a limit was specified using
setLimit(int)
, that limit is applied to each query independently.- Parameters:
queries
- list of queries.- Returns:
- results of the queries, one list of results per input query, in the same order as the input.
-
schema
-
queryExhaustively
protected static <T> com.google.common.collect.ImmutableList<T> queryExhaustively(Supplier<? extends InternalQuery<T, ?>> querySupplier, Predicate<T> predicate) Query a predicate repeatedly until all results are exhausted.Capable of iterating through all results regardless of limits. The passed
querySupplier
may choose to pre-set limits or not; this only affects the number of queries that may be issued, not the size of the final results.Since multiple queries may be issued, this method is subject to races when the result set changes mid-iteration. This may result in skipped results, if an entity gets modified to jump to the front of the list after this method has passed it. It may also result in duplicate results, if an entity at the end of one batch of results gets pushed back further, putting it at the beginning of the next batch. This race cannot be avoided unless we change the underlying index interface to support true continuation tokens.
- Type Parameters:
T
- result type.- Parameters:
querySupplier
- supplier for queries. Callers will generally pass a lambda that invokes an underlyingProvider<InternalFooQuery>
, since the instances are not reusable. The lambda may also call additional methods on the newly-created query, such asenforceVisibility(boolean)
.predicate
- predicate to search for.- Returns:
- exhaustive list of results, subject to the race condition described above.
-