public class GroupByStrategyV1 extends Object implements GroupByStrategy
| Constructor and Description |
|---|
GroupByStrategyV1(com.google.common.base.Supplier<GroupByQueryConfig> configSupplier,
GroupByQueryEngine engine,
QueryWatcher queryWatcher,
NonBlockingPool<ByteBuffer> bufferPool) |
| 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. |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateMergeFn, createResultComparator@Inject public GroupByStrategyV1(com.google.common.base.Supplier<GroupByQueryConfig> configSupplier, GroupByQueryEngine engine, QueryWatcher queryWatcher, NonBlockingPool<ByteBuffer> bufferPool)
public GroupByQueryResource prepareResource(GroupByQuery query)
GroupByStrategyGroupByQueryQueryToolChest.mergeResults(QueryRunner) for a
particular query. That method is also the primary caller of this method.
Used by GroupByQueryQueryToolChest.mergeResults(QueryRunner).prepareResource in interface GroupByStrategyquery - a groupBy query to be processedpublic boolean isCacheable(boolean willMergeRunners)
GroupByStrategyGroupByQueryQueryToolChest.getCacheStrategy(GroupByQuery).isCacheable in interface GroupByStrategywillMergeRunners - 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.public boolean doMergeResults(GroupByQuery query)
GroupByStrategyGroupByQueryQueryToolChest.mergeResults(QueryRunner).doMergeResults in interface GroupByStrategypublic Sequence<ResultRow> mergeResults(QueryRunner<ResultRow> baseRunner, GroupByQuery query, ResponseContext responseContext)
GroupByStrategyQueryRunner 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.mergeResults in interface GroupByStrategybaseRunner - base query runnerquery - the groupBy query to run inside the base query runnerresponseContext - the response context to pass to the base query runnerpublic Sequence<ResultRow> applyPostProcessing(Sequence<ResultRow> results, GroupByQuery query)
GroupByStrategyGroupByQuery "postProcessingFn", which is responsible for HavingSpec and LimitSpec.applyPostProcessing in interface GroupByStrategyresults - sequence of resultsquery - the groupBy querypublic Sequence<ResultRow> processSubqueryResult(GroupByQuery subquery, GroupByQuery query, GroupByQueryResource resource, Sequence<ResultRow> subqueryResult, boolean wasQueryPushedDown)
GroupByStrategyGroupByQueryQueryToolChest.mergeResults(QueryRunner) when it needs to process a subquery.processSubqueryResult in interface GroupByStrategysubquery - inner queryquery - outer queryresource - resources returned by GroupByStrategy.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)public Sequence<ResultRow> processSubtotalsSpec(GroupByQuery query, GroupByQueryResource resource, Sequence<ResultRow> queryResult)
GroupByStrategyGroupByQueryQueryToolChest.mergeResults(QueryRunner) when it needs to generate subtotals.processSubtotalsSpec in interface GroupByStrategyquery - query that has a "subtotalsSpec"resource - resources returned by GroupByStrategy.prepareResource(GroupByQuery)queryResult - result rows from the main querypublic QueryRunner<ResultRow> mergeRunners(com.google.common.util.concurrent.ListeningExecutorService exec, Iterable<QueryRunner<ResultRow>> queryRunners)
GroupByStrategyGroupByQueryRunnerFactory.mergeRunners(ExecutorService, Iterable). In
that sense, it is intended to go along with GroupByStrategy.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).mergeRunners in interface GroupByStrategyexec - executor service used for parallel execution of the query runnersqueryRunners - collection of query runners to mergepublic Sequence<ResultRow> process(GroupByQuery query, StorageAdapter storageAdapter)
GroupByStrategyStorageAdapter. 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).process in interface GroupByStrategyquery - the groupBy querystorageAdapter - storage adatper for the segment in questionpublic boolean supportsNestedQueryPushDown()
GroupByStrategyGroupByQueryQueryToolChest.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.)supportsNestedQueryPushDown in interface GroupByStrategyCopyright © 2011–2020 The Apache Software Foundation. All rights reserved.