From 0ff6356b7e1d7298b78806a691e802a8a04a08f8 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Tue, 21 Feb 2017 18:48:12 +0100 Subject: [PATCH] Revert "Never reduce the same agg twice" This change reverts 5e4ba4a60ecc1169e86c1dd517ed05a225c5278b Incremental reduction of aggs should also work with a single aggregation now that InternalTopHits.equals is fixed. --- .../search/aggregations/AggregatorTestCase.java | 6 +++--- .../search/aggregations/InternalAggregationTestCase.java | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java index 62249f83333..aa23dfdb7a5 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java @@ -180,9 +180,9 @@ public abstract class AggregatorTestCase extends ESTestCase { if (aggs.isEmpty()) { return null; } else { - if (randomBoolean() && aggs.size() > 1) { - // never do am incremental reduce with only one - some aggs can't deal with this. - List internalAggregations = randomSubsetOf(randomIntBetween(2, aggs.size()), aggs); + if (randomBoolean()) { + // sometimes do an incremental reduce + List internalAggregations = randomSubsetOf(randomIntBetween(1, aggs.size()), aggs); A internalAgg = (A) aggs.get(0).doReduce(internalAggregations, new InternalAggregation.ReduceContext(root.context().bigArrays(), null, false)); aggs.removeAll(internalAggregations); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/InternalAggregationTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/InternalAggregationTestCase.java index 3ec00ce335c..4e2ab0188c9 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/InternalAggregationTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/InternalAggregationTestCase.java @@ -57,10 +57,10 @@ public abstract class InternalAggregationTestCase inputs.add(t); toReduce.add(t); } - if (randomBoolean() && toReduceSize > 1) { - // never do am incremental reduce with only one - some aggs can't deal with this. - List internalAggregations = randomSubsetOf(randomIntBetween(2, toReduceSize), toReduce); - InternalAggregation.ReduceContext context = new InternalAggregation.ReduceContext(null, null, true); + if (randomBoolean()) { + // we leave at least one in the list + List internalAggregations = randomSubsetOf(randomIntBetween(1, toReduceSize), toReduce); + InternalAggregation.ReduceContext context = new InternalAggregation.ReduceContext(null, null, false); @SuppressWarnings("unchecked") T reduced = (T) inputs.get(0).reduce(internalAggregations, context); toReduce.removeAll(internalAggregations);