Skip to content

Commit

Permalink
Never reduce the same agg twice
Browse files Browse the repository at this point in the history
Some randomization caused reduction of the same agg multiple times
which causes issues on some aggregations.

Relates to #23253
  • Loading branch information
s1monw committed Feb 21, 2017
1 parent 489f389 commit 5e4ba4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduc
if (aggs.isEmpty()) {
return null;
} else {
if (randomBoolean()) {
// sometimes do an incremental reduce
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(1, aggs.size()), aggs);
if (randomBoolean() && aggs.size() > 1) {
// never do am incremental reduce with only one - some aggs can't deal with this.
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(2, aggs.size()), aggs);
A internalAgg = (A) aggs.get(0).doReduce(internalAggregations,
new InternalAggregation.ReduceContext(root.context().bigArrays(), null, false));
aggs.removeAll(internalAggregations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public final void testReduceRandom() {
inputs.add(t);
toReduce.add(t);
}
if (randomBoolean()) {
// we leave at least one in the list
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(1, toReduceSize), toReduce);
if (randomBoolean() && toReduceSize > 1) {
// never do am incremental reduce with only one - some aggs can't deal with this.
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(2, toReduceSize), toReduce);
InternalAggregation.ReduceContext context = new InternalAggregation.ReduceContext(null, null, true);
@SuppressWarnings("unchecked")
T reduced = (T) inputs.get(0).reduce(internalAggregations, context);
Expand Down

0 comments on commit 5e4ba4a

Please sign in to comment.