Skip to content

Commit ff58e0c

Browse files
authored
Construct list manually in AggregatorsReducer#get (elastic#119565) (elastic#119568)
1 parent 5386ace commit ff58e0c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

server/src/main/java/org/elasticsearch/search/aggregations/AggregatorsReducer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
import org.elasticsearch.core.Releasable;
1313
import org.elasticsearch.core.Releasables;
1414

15+
import java.util.ArrayList;
16+
import java.util.Collection;
1517
import java.util.HashMap;
18+
import java.util.List;
1619
import java.util.Map;
1720

1821
/**
@@ -54,7 +57,12 @@ public void accept(InternalAggregations aggregations) {
5457
* returns the reduced {@link InternalAggregations}.
5558
*/
5659
public InternalAggregations get() {
57-
return InternalAggregations.from(aggByName.values().stream().map(AggregatorReducer::get).toList());
60+
final Collection<AggregatorReducer> reducers = aggByName.values();
61+
final List<InternalAggregation> aggs = new ArrayList<>(reducers.size());
62+
for (AggregatorReducer reducer : reducers) {
63+
aggs.add(reducer.get());
64+
}
65+
return InternalAggregations.from(aggs);
5866
}
5967

6068
@Override

0 commit comments

Comments
 (0)