public interface GroupByStrategy
| Modifier and Type | Method and Description |
|---|---|
Sequence<ResultRow> |
applyPostProcessing(Sequence<ResultRow> results,
GroupByQuery query)
Apply the
GroupByQuery "postProcessingFn", which is responsible for HavingSpec and LimitSpec. |
default BinaryOperator<ResultRow> |
createMergeFn(Query<ResultRow> query)
See
QueryToolChest.createMergeFn(Query) for details, allows
GroupByQueryQueryToolChest to delegate implementation to the strategy |
default Comparator<ResultRow> |
createResultComparator(Query<ResultRow> queryParam)
See
QueryToolChest.createResultComparator(Query), allows
GroupByQueryQueryToolChest to delegate implementation to the strategy |
boolean |
doMergeResults(GroupByQuery query)
Indicates if this query should undergo "mergeResults" or not.
|
boolean |
isCacheable(boolean willMergeRunners)
Indicates if results from this query are cacheable or not.
|
Sequence<ResultRow> |
mergeResults(QueryRunner<ResultRow> baseRunner,
GroupByQuery query,
ResponseContext responseContext)
Runs a provided
QueryRunner on a provided GroupByQuery, which is assumed to return rows that are
properly sorted (by timestamp and dimensions) but not necessarily fully merged (that is, there may be adjacent
rows with the same timestamp and dimensions) and without PostAggregators computed. |
QueryRunner<ResultRow> |
mergeRunners(com.google.common.util.concurrent.ListeningExecutorService exec,
Iterable<QueryRunner<ResultRow>> queryRunners)
Merge a variety of single-segment query runners into a combined runner.
|
GroupByQueryResource |
prepareResource(GroupByQuery query)
Initializes resources required to run
GroupByQueryQueryToolChest.mergeResults(QueryRunner) for a
particular query. |
Sequence<ResultRow> |
process(GroupByQuery query,
StorageAdapter storageAdapter)
Process a groupBy query on a single
StorageAdapter. |
Sequence<ResultRow> |
processSubqueryResult(GroupByQuery subquery,
GroupByQuery query,
GroupByQueryResource resource,
Sequence<ResultRow> subqueryResult,
boolean wasQueryPushedDown)
Called by
GroupByQueryQueryToolChest.mergeResults(QueryRunner) when it needs to process a subquery. |
Sequence<ResultRow> |
processSubtotalsSpec(GroupByQuery query,
GroupByQueryResource resource,
Sequence<ResultRow> queryResult)
Called by
GroupByQueryQueryToolChest.mergeResults(QueryRunner) when it needs to generate subtotals. |
boolean |
supportsNestedQueryPushDown()
Returns whether this strategy supports pushing down outer queries.
|
GroupByQueryResource prepareResource(GroupByQuery query)
GroupByQueryQueryToolChest.mergeResults(QueryRunner) for a
particular query. That method is also the primary caller of this method.
Used by GroupByQueryQueryToolChest.mergeResults(QueryRunner).query - a groupBy query to be processedboolean isCacheable(boolean willMergeRunners)
GroupByQueryQueryToolChest.getCacheStrategy(GroupByQuery).willMergeRunners - indicates that QueryRunnerFactory.mergeRunners(ExecutorService, Iterable) will be
called on the cached by-segment results. Can be used to distinguish if we are running on
a broker or data node.boolean doMergeResults(GroupByQuery query)
GroupByQueryQueryToolChest.mergeResults(QueryRunner).Sequence<ResultRow> mergeResults(QueryRunner<ResultRow> baseRunner, GroupByQuery query, ResponseContext responseContext)
QueryRunner on a provided GroupByQuery, which is assumed to return rows that are
properly sorted (by timestamp and dimensions) but not necessarily fully merged (that is, there may be adjacent
rows with the same timestamp and dimensions) and without PostAggregators computed. This method will fully merge
the rows, apply PostAggregators, and return the resulting Sequence.
The query will be modified before passing it down to the base runner. For example, "having" clauses will be
removed and various context parameters will be adjusted.
Despite the similar name, this method is much reduced in scope compared to
GroupByQueryQueryToolChest.mergeResults(QueryRunner). That method does delegate to this one at some points,
but has a truckload of other responsibility, including computing outer query results (if there are subqueries),
computing subtotals (like GROUPING SETS), and computing the havingSpec and limitSpec.baseRunner - base query runnerquery - the groupBy query to run inside the base query runnerresponseContext - the response context to pass to the base query runner@Nullable default BinaryOperator<ResultRow> createMergeFn(Query<ResultRow> query)
QueryToolChest.createMergeFn(Query) for details, allows
GroupByQueryQueryToolChest to delegate implementation to the strategy@Nullable default Comparator<ResultRow> createResultComparator(Query<ResultRow> queryParam)
QueryToolChest.createResultComparator(Query), allows
GroupByQueryQueryToolChest to delegate implementation to the strategySequence<ResultRow> applyPostProcessing(Sequence<ResultRow> results, GroupByQuery query)
GroupByQuery "postProcessingFn", which is responsible for HavingSpec and LimitSpec.results - sequence of resultsquery - the groupBy querySequence<ResultRow> processSubqueryResult(GroupByQuery subquery, GroupByQuery query, GroupByQueryResource resource, Sequence<ResultRow> subqueryResult, boolean wasQueryPushedDown)
GroupByQueryQueryToolChest.mergeResults(QueryRunner) when it needs to process a subquery.subquery - inner queryquery - outer queryresource - resources returned by prepareResource(GroupByQuery)subqueryResult - result rows from the subquerywasQueryPushedDown - true if the outer query was pushed down (so we only need to merge the outer query's
results, not run it from scratch like a normal outer query)Sequence<ResultRow> processSubtotalsSpec(GroupByQuery query, GroupByQueryResource resource, Sequence<ResultRow> queryResult)
GroupByQueryQueryToolChest.mergeResults(QueryRunner) when it needs to generate subtotals.query - query that has a "subtotalsSpec"resource - resources returned by prepareResource(GroupByQuery)queryResult - result rows from the main queryQueryRunner<ResultRow> mergeRunners(com.google.common.util.concurrent.ListeningExecutorService exec, Iterable<QueryRunner<ResultRow>> queryRunners)
GroupByQueryRunnerFactory.mergeRunners(ExecutorService, Iterable). In
that sense, it is intended to go along with process(GroupByQuery, StorageAdapter) (the runners created
by that method will be fed into this method).
This method is only called on data servers, like Historicals (not the Broker).exec - executor service used for parallel execution of the query runnersqueryRunners - collection of query runners to mergeSequence<ResultRow> process(GroupByQuery query, StorageAdapter storageAdapter)
StorageAdapter. This is used by
GroupByQueryRunnerFactory.createRunner(org.apache.druid.segment.Segment) to create per-segment
QueryRunners.
This method is only called on data servers, like Historicals (not the Broker).query - the groupBy querystorageAdapter - storage adatper for the segment in questionboolean supportsNestedQueryPushDown()
GroupByQueryQueryToolChest.mergeResults(QueryRunner) when it decides whether or not to push down an
outer query from the Broker to data servers, like Historicals.
Can be removed when the "v1" groupBy strategy is removed. ("v1" returns false, and "v2" returns true.)Copyright © 2011–2020 The Apache Software Foundation. All rights reserved.