Revert "Never reduce the same agg twice"

This change reverts 5e4ba4a60e
Incremental reduction of aggs should also work with a single aggregation now that InternalTopHits.equals
 is fixed.
This commit is contained in:
Jim Ferenczi 2017-02-21 18:48:12 +01:00
parent ce625ebdcc
commit 0ff6356b7e
2 changed files with 7 additions and 7 deletions

View File

@ -180,9 +180,9 @@ public abstract class AggregatorTestCase extends ESTestCase {
if (aggs.isEmpty()) { if (aggs.isEmpty()) {
return null; return null;
} else { } else {
if (randomBoolean() && aggs.size() > 1) { if (randomBoolean()) {
// never do am incremental reduce with only one - some aggs can't deal with this. // sometimes do an incremental reduce
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(2, aggs.size()), aggs); List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(1, aggs.size()), aggs);
A internalAgg = (A) aggs.get(0).doReduce(internalAggregations, A internalAgg = (A) aggs.get(0).doReduce(internalAggregations,
new InternalAggregation.ReduceContext(root.context().bigArrays(), null, false)); new InternalAggregation.ReduceContext(root.context().bigArrays(), null, false));
aggs.removeAll(internalAggregations); aggs.removeAll(internalAggregations);

View File

@ -57,10 +57,10 @@ public abstract class InternalAggregationTestCase<T extends InternalAggregation>
inputs.add(t); inputs.add(t);
toReduce.add(t); toReduce.add(t);
} }
if (randomBoolean() && toReduceSize > 1) { if (randomBoolean()) {
// never do am incremental reduce with only one - some aggs can't deal with this. // we leave at least one in the list
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(2, toReduceSize), toReduce); List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(1, toReduceSize), toReduce);
InternalAggregation.ReduceContext context = new InternalAggregation.ReduceContext(null, null, true); InternalAggregation.ReduceContext context = new InternalAggregation.ReduceContext(null, null, false);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
T reduced = (T) inputs.get(0).reduce(internalAggregations, context); T reduced = (T) inputs.get(0).reduce(internalAggregations, context);
toReduce.removeAll(internalAggregations); toReduce.removeAll(internalAggregations);