don't override context when not finalizing

This commit is contained in:
Xavier Léauté 2014-04-18 16:26:21 -07:00
parent 68e8cda2da
commit 597e55ab50
1 changed files with 8 additions and 2 deletions

View File

@ -50,8 +50,13 @@ public class FinalizeResultsQueryRunner<T> implements QueryRunner<T>
{ {
final boolean isBySegment = query.getContextBySegment(false); final boolean isBySegment = query.getContextBySegment(false);
final boolean shouldFinalize = query.getContextFinalize(true); final boolean shouldFinalize = query.getContextFinalize(true);
Function<T, T> finalizerFn;
final Query<T> queryToRun;
final Function<T, T> finalizerFn;
if (shouldFinalize) { if (shouldFinalize) {
queryToRun = query.withOverriddenContext(ImmutableMap.<String, Object>of("finalize", false));
if (isBySegment) { if (isBySegment) {
finalizerFn = new Function<T, T>() finalizerFn = new Function<T, T>()
{ {
@ -99,6 +104,7 @@ public class FinalizeResultsQueryRunner<T> implements QueryRunner<T>
} }
} else { } else {
// finalize is false here. // finalize is false here.
queryToRun = query;
finalizerFn = toolChest.makePostComputeManipulatorFn( finalizerFn = toolChest.makePostComputeManipulatorFn(
query, query,
new MetricManipulationFn() new MetricManipulationFn()
@ -113,7 +119,7 @@ public class FinalizeResultsQueryRunner<T> implements QueryRunner<T>
} }
return Sequences.map( return Sequences.map(
baseRunner.run(query.withOverriddenContext(ImmutableMap.<String, Object>of("finalize", false))), baseRunner.run(queryToRun),
finalizerFn finalizerFn
); );