Class QueryProcessor<T>
- java.lang.Object
- 
- com.google.gerrit.index.query.QueryProcessor<T>
 
- 
- Direct Known Subclasses:
- AccountQueryProcessor,- ChangeQueryProcessor,- GroupQueryProcessor,- ProjectQueryProcessor
 
 public abstract class QueryProcessor<T> extends Object Lower-level implementation for executing a single query over a secondary index.Instances are one-time-use. Other singleton classes should inject a Provider rather than holding on to a single instance. 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classQueryProcessor.Metrics
 - 
Field SummaryFields Modifier and Type Field Description protected intstart
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedQueryProcessor(com.google.gerrit.metrics.MetricMaker metricMaker, SchemaDefinitions<T> schemaDef, IndexConfig indexConfig, IndexCollection<?,T,? extends Index<?,T>> indexes, IndexRewriter<T> rewriter, String limitField, IntSupplier permittedLimit)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected QueryOptionscreateOptions(IndexConfig indexConfig, int start, int limit, Set<String> requestedFields)QueryProcessor<T>enforceVisibility(boolean enforce)Specify whether to enforce visibility by filtering out results that are not visible to the user.protected abstract Predicate<T>enforceVisibility(Predicate<T> pred)Invoked after the query was rewritten.protected abstract StringformatForLogging(T t)booleanisDisabled()Check whether querying should be disabled.QueryResult<T>query(Predicate<T> query)Query for entities that match a structured query.List<QueryResult<T>>query(List<Predicate<T>> queries)Perform multiple queries in parallel.QueryProcessor<T>setNoLimit(boolean isNoLimit)QueryProcessor<T>setRequestedFields(Set<String> fields)QueryProcessor<T>setStart(int n)QueryProcessor<T>setUserProvidedLimit(int n)Set an end-user-provided limit on the number of results returned.
 
- 
- 
- 
Constructor Detail- 
QueryProcessorprotected QueryProcessor(com.google.gerrit.metrics.MetricMaker metricMaker, SchemaDefinitions<T> schemaDef, IndexConfig indexConfig, IndexCollection<?,T,? extends Index<?,T>> indexes, IndexRewriter<T> rewriter, String limitField, IntSupplier permittedLimit)
 
- 
 - 
Method Detail- 
setStartpublic QueryProcessor<T> setStart(int n) 
 - 
enforceVisibilitypublic QueryProcessor<T> enforceVisibility(boolean enforce) Specify whether to enforce visibility by filtering out results that are not visible to the user.Enforcing visibility may have performance consequences, as the index system may need to post-filter a large number of results to fill even a modest limit. If visibility is enforced, the user's queryLimitglobal capability is also used to bound the total number of results. If this capability is non-positive, this results in the entire query processor beingdisabled.- Parameters:
- enforce- whether to enforce visibility.
- Returns:
- this.
 
 - 
setUserProvidedLimitpublic QueryProcessor<T> setUserProvidedLimit(int n) Set an end-user-provided limit on the number of results returned.Since this limit is provided by an end user, it may exceed the limit that they are authorized to use. This is allowed; the processor will take multiple possible limits into account and choose the one that makes the most sense. - Parameters:
- n- limit; zero or negative means no limit.
- Returns:
- this.
 
 - 
setNoLimitpublic QueryProcessor<T> setNoLimit(boolean isNoLimit) 
 - 
setRequestedFieldspublic QueryProcessor<T> setRequestedFields(Set<String> fields) 
 - 
querypublic QueryResult<T> query(Predicate<T> query) throws QueryParseException Query for entities that match a structured query.- Parameters:
- query- the query.
- Returns:
- results of the query.
- Throws:
- QueryParseException
- See Also:
- query(List)
 
 - 
querypublic List<QueryResult<T>> query(List<Predicate<T>> queries) throws QueryParseException Perform multiple queries in parallel.If querying is disabled, short-circuits the index and returns empty results. Callers that wish to distinguish this case from a query returning no results from the index may call isDisabled()themselves.- Parameters:
- queries- list of queries.
- Returns:
- results of the queries, one QueryResult per input query, in the same order as the input.
- Throws:
- QueryParseException
 
 - 
createOptionsprotected QueryOptions createOptions(IndexConfig indexConfig, int start, int limit, Set<String> requestedFields) 
 - 
enforceVisibilityprotected abstract Predicate<T> enforceVisibility(Predicate<T> pred) Invoked after the query was rewritten. Subclasses must overwrite this method to filter out results that are not visible to the calling user.- Parameters:
- pred- the query
- Returns:
- the modified query
 
 - 
isDisabledpublic boolean isDisabled() Check whether querying should be disabled.Currently, the only condition that can disable the whole query processor is if both visibility is enforcedand the user has a non-positive maximum value for thequeryLimitcapability.If querying is disabled, all calls to query(Predicate)andquery(List)will return empty results. This method can be used if callers wish to distinguish this case from a query returning no results from the index.- Returns:
- true if querying should be disabled.
 
 
- 
 
-