Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ public Sequence<Row> run(Query<Row> query, Map<String, Object> responseContext)
return runner.run(query, responseContext);
}

if (query.getContextBoolean(GROUP_BY_MERGE_KEY, true)) {
final GroupByQuery groupByQuery = (GroupByQuery) query;
if (strategySelector.strategize(groupByQuery).doMergeResults(groupByQuery)) {
return initAndMergeGroupByResults(
(GroupByQuery) query,
groupByQuery,
runner,
responseContext
);
Expand Down Expand Up @@ -181,7 +182,7 @@ private Sequence<Row> mergeGroupByResults(
subquery.withOverriddenContext(
ImmutableMap.<String, Object>of(
//setting sort to false avoids unnecessary sorting while merging results. we only need to sort
//in the end when returning results to user.
//in the end when returning results to user. (note this is only respected by groupBy v1)
GroupByQueryHelper.CTX_KEY_SORT_RESULTS,
false
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public interface GroupByStrategy
*/
boolean isCacheable(boolean willMergeRunners);

/**
* Indicates if this query should undergo "mergeResults" or not.
*/
boolean doMergeResults(final GroupByQuery query);

/**
* Decorate a runner with an interval chunking decorator.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public QueryRunner<Row> createIntervalChunkingRunner(
return decorator.decorate(runner, toolChest);
}

@Override
public boolean doMergeResults(final GroupByQuery query)
{
return query.getContextBoolean(GroupByQueryQueryToolChest.GROUP_BY_MERGE_KEY, true);
}

@Override
public Sequence<Row> mergeResults(
final QueryRunner<Row> baseRunner,
Expand Down Expand Up @@ -131,10 +137,10 @@ public Sequence<Row> mergeResults(
ImmutableMap.<String, Object>of(
"finalize", false,
//setting sort to false avoids unnecessary sorting while merging results. we only need to sort
//in the end when returning results to user.
//in the end when returning results to user. (note this is only respected by groupBy v1)
GroupByQueryHelper.CTX_KEY_SORT_RESULTS, false,
//no merging needed at historicals because GroupByQueryRunnerFactory.mergeRunners(..) would return
//merged results
//merged results. (note this is only respected by groupBy v1)
GroupByQueryQueryToolChest.GROUP_BY_MERGE_KEY, false,
GroupByQueryConfig.CTX_KEY_STRATEGY, GroupByStrategySelector.STRATEGY_V1
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ public boolean isCacheable(boolean willMergeRunners)
return willMergeRunners;
}

@Override
public boolean doMergeResults(final GroupByQuery query)
{
return true;
}

@Override
public QueryRunner<Row> createIntervalChunkingRunner(
final IntervalChunkingQueryRunnerDecorator decorator,
Expand Down