diff --git a/modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/ParentJoinAggregator.java b/modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/ParentJoinAggregator.java index ed4a476383a0f..437acd1e72c4c 100644 --- a/modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/ParentJoinAggregator.java +++ b/modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/ParentJoinAggregator.java @@ -113,12 +113,7 @@ public void collect(int docId, long owningBucketOrd) throws IOException { } @Override - public void postCollection() throws IOException { - // Delaying until beforeBuildingBuckets - } - - @Override - protected void beforeBuildingBuckets(long[] ordsToCollect) throws IOException { + protected void prepareSubAggs(long[] bucketOrdsToCollect) throws IOException { IndexReader indexReader = context().searcher().getIndexReader(); for (LeafReaderContext ctx : indexReader.leaves()) { Scorer childDocsScorer = outFilter.scorer(ctx); @@ -160,14 +155,13 @@ public int docID() { * structure that maps a primitive long to a list of primitive * longs. */ - for (long owningBucketOrd: ordsToCollect) { - if (collectionStrategy.exists(owningBucketOrd, globalOrdinal)) { - collectBucket(sub, docId, owningBucketOrd); + for (long o: bucketOrdsToCollect) { + if (collectionStrategy.exists(o, globalOrdinal)) { + collectBucket(sub, docId, o); } } } } - super.postCollection(); // Run post collection after collecting the sub-aggs } @Override diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/search/TransportSearchIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/search/TransportSearchIT.java index 2f295a1c8a395..c18ff5352fdf2 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/search/TransportSearchIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/search/TransportSearchIT.java @@ -597,8 +597,5 @@ public ScoreMode scoreMode() { @Override public void preCollection() throws IOException {} - - @Override - public void postCollection() throws IOException {} } } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/profile/aggregation/AggregationProfilerIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/profile/aggregation/AggregationProfilerIT.java index 4580f499d2370..0408ecb21f2ee 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/profile/aggregation/AggregationProfilerIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/profile/aggregation/AggregationProfilerIT.java @@ -52,7 +52,6 @@ public class AggregationProfilerIT extends ESIntegTestCase { private static final String BUILD_LEAF_COLLECTOR = AggregationTimingType.BUILD_LEAF_COLLECTOR.toString(); private static final String COLLECT = AggregationTimingType.COLLECT.toString(); - private static final String POST_COLLECTION = AggregationTimingType.POST_COLLECTION.toString(); private static final String INITIALIZE = AggregationTimingType.INITIALIZE.toString(); private static final String BUILD_AGGREGATION = AggregationTimingType.BUILD_AGGREGATION.toString(); private static final String REDUCE = AggregationTimingType.REDUCE.toString(); @@ -60,13 +59,11 @@ public class AggregationProfilerIT extends ESIntegTestCase { INITIALIZE, BUILD_LEAF_COLLECTOR, COLLECT, - POST_COLLECTION, BUILD_AGGREGATION, REDUCE, INITIALIZE + "_count", BUILD_LEAF_COLLECTOR + "_count", COLLECT + "_count", - POST_COLLECTION + "_count", BUILD_AGGREGATION + "_count", REDUCE + "_count" ); @@ -330,7 +327,6 @@ public void testDiversifiedAggProfile() { assertThat(diversifyBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(diversifyBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(diversifyBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(diversifyBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(diversifyBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(diversifyBreakdown.get(REDUCE), equalTo(0L)); assertThat(diversifyAggResult.getDebugInfo(), equalTo(Map.of(DEFERRED, List.of("max")))); @@ -347,7 +343,6 @@ public void testDiversifiedAggProfile() { assertThat(diversifyBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(diversifyBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(diversifyBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(diversifyBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(maxBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(maxBreakdown.get(REDUCE), equalTo(0L)); assertThat(maxAggResult.getDebugInfo(), equalTo(Map.of())); @@ -391,7 +386,6 @@ public void testComplexProfile() { assertThat(histoBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(histoBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(histoBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(histoBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(histoBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(histoBreakdown.get(REDUCE), equalTo(0L)); Map histoDebugInfo = histoAggResult.getDebugInfo(); @@ -413,7 +407,6 @@ public void testComplexProfile() { assertThat(tagsBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(tagsBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(tagsBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(tagsBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(tagsBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(tagsBreakdown.get(REDUCE), equalTo(0L)); assertRemapTermsDebugInfo(tagsAggResult); @@ -432,7 +425,6 @@ public void testComplexProfile() { assertThat(avgBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(avgBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(avgBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(avgBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(avgBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(avgBreakdown.get(REDUCE), equalTo(0L)); assertThat(avgAggResult.getDebugInfo(), equalTo(Map.of())); @@ -448,7 +440,6 @@ public void testComplexProfile() { assertThat(maxBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(maxBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(maxBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(maxBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(maxBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(maxBreakdown.get(REDUCE), equalTo(0L)); assertThat(maxAggResult.getDebugInfo(), equalTo(Map.of())); @@ -464,7 +455,6 @@ public void testComplexProfile() { assertThat(stringsBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(stringsBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(stringsBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(stringsBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(stringsBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(stringsBreakdown.get(REDUCE), equalTo(0L)); assertRemapTermsDebugInfo(stringsAggResult); @@ -483,7 +473,6 @@ public void testComplexProfile() { assertThat(avgBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(avgBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(avgBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(avgBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(avgBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(avgBreakdown.get(REDUCE), equalTo(0L)); assertThat(avgAggResult.getDebugInfo(), equalTo(Map.of())); @@ -499,7 +488,6 @@ public void testComplexProfile() { assertThat(maxBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(maxBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(maxBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(maxBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(maxBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(maxBreakdown.get(REDUCE), equalTo(0L)); assertThat(maxAggResult.getDebugInfo(), equalTo(Map.of())); @@ -516,7 +504,6 @@ public void testComplexProfile() { assertThat(tagsBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(tagsBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(tagsBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(tagsBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(tagsBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(tagsBreakdown.get(REDUCE), equalTo(0L)); assertRemapTermsDebugInfo(tagsAggResult); @@ -535,7 +522,6 @@ public void testComplexProfile() { assertThat(avgBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(avgBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(avgBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(avgBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(avgBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(avgBreakdown.get(REDUCE), equalTo(0L)); assertThat(avgAggResult.getDebugInfo(), equalTo(Map.of())); @@ -551,7 +537,6 @@ public void testComplexProfile() { assertThat(maxBreakdown.get(INITIALIZE), greaterThan(0L)); assertThat(maxBreakdown.get(BUILD_LEAF_COLLECTOR), greaterThan(0L)); assertThat(maxBreakdown.get(COLLECT), greaterThan(0L)); - assertThat(maxBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(maxBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(maxBreakdown.get(REDUCE), equalTo(0L)); assertThat(maxAggResult.getDebugInfo(), equalTo(Map.of())); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java b/server/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java index ab7a8a612c91a..629d9c558054c 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java @@ -119,7 +119,6 @@ public void execute(SearchContext context) { context.aggregations().resetBucketMultiConsumer(); for (Aggregator aggregator : context.aggregations().aggregators()) { try { - aggregator.postCollection(); aggregations.add(aggregator.buildTopLevel()); } catch (IOException e) { throw new AggregationExecutionException("Failed to build aggregation [" + aggregator.name() + "]", e); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java index 061640e73b510..ac42a0289921e 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/Aggregator.java @@ -142,12 +142,12 @@ public interface BucketComparator { /** * Build the results of this aggregation. - * @param owningBucketOrds the ordinals of the buckets that we want to + * @param ordsToCollect the ordinals of the buckets that we want to * collect from this aggregation * @return the results for each ordinal, in the same order as the array * of ordinals */ - public abstract InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws IOException; + public abstract InternalAggregation[] buildAggregations(long[] ordsToCollect) throws IOException; /** * Build the result of this aggregation if it is at the "top level" diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorBase.java b/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorBase.java index a110d0f20fb34..93eaa00a86d74 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorBase.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorBase.java @@ -95,10 +95,6 @@ public void preCollection() throws IOException { badState(); } - @Override - public void postCollection() throws IOException { - badState(); - } @Override public ScoreMode scoreMode() { badState(); @@ -248,19 +244,6 @@ public SearchContext context() { return context; } - /** - * Called after collection of all document is done. - *

- * Warning: this is not final only to allow the parent join aggregator - * to delay this until building buckets. - */ - @Override - public void postCollection() throws IOException { - // post-collect this agg before subs to make it possible to buffer and then replay in postCollection() - doPostCollection(); - collectableSubAggregators.postCollection(); - } - /** Called upon release of the aggregator. */ @Override public void close() { @@ -274,12 +257,6 @@ public void close() { /** Release instance-specific data. */ protected void doClose() {} - /** - * Can be overridden by aggregator implementation to be called back when the collection phase ends. - */ - protected void doPostCollection() throws IOException { - } - protected final InternalAggregations buildEmptySubAggregations() { List aggs = new ArrayList<>(); for (Aggregator aggregator : subAggregators) { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/BucketCollector.java b/server/src/main/java/org/elasticsearch/search/aggregations/BucketCollector.java index c50dd615c7b34..7da1ce52e9522 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/BucketCollector.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/BucketCollector.java @@ -42,10 +42,6 @@ public void preCollection() throws IOException { // no-op } @Override - public void postCollection() throws IOException { - // no-op - } - @Override public ScoreMode scoreMode() { return ScoreMode.COMPLETE_NO_SCORES; } @@ -58,10 +54,4 @@ public ScoreMode scoreMode() { * Pre collection callback. */ public abstract void preCollection() throws IOException; - - /** - * Post-collection callback. - */ - public abstract void postCollection() throws IOException; - } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketCollector.java b/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketCollector.java index 552ad8c024ddc..61e2ec802ec96 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketCollector.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketCollector.java @@ -126,13 +126,6 @@ public void preCollection() throws IOException { } } - @Override - public void postCollection() throws IOException { - for (BucketCollector collector : collectors) { - collector.postCollection(); - } - } - @Override public String toString() { return Arrays.toString(collectors); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BestBucketsDeferringCollector.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BestBucketsDeferringCollector.java index 2c9ca8d8ae7e9..e75bdcf86efe0 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BestBucketsDeferringCollector.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BestBucketsDeferringCollector.java @@ -70,7 +70,6 @@ static class Entry { protected PackedLongValues.Builder docDeltasBuilder; protected PackedLongValues.Builder bucketsBuilder; protected long maxBucket = -1; - protected boolean finished = false; protected LongHash selectedBuckets; /** @@ -136,20 +135,12 @@ public void preCollection() throws IOException { collector.preCollection(); } - @Override - public void postCollection() throws IOException { - finishLeaf(); - finished = true; - } - /** * Replay the wrapped collector, but only on a selection of buckets. */ @Override public void prepareSelectedBuckets(long... selectedBuckets) throws IOException { - if (finished == false) { - throw new IllegalStateException("Cannot replay yet, collection is not finished: postCollect() has not been called"); - } + finishLeaf(); if (this.selectedBuckets != null) { throw new IllegalStateException("Already been replayed"); } @@ -201,7 +192,6 @@ public void prepareSelectedBuckets(long... selectedBuckets) throws IOException { // continue with the following leaf } } - collector.postCollection(); } /** diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java index cffcb61aa06af..e1fe8ca6415a7 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java @@ -168,9 +168,9 @@ public final int bucketDocCount(long bucketOrd) { } /** - * Hook to allow taking an action before building buckets. + * Hook to allow taking an action before building child agg result. */ - protected void beforeBuildingBuckets(long[] ordsToCollect) throws IOException {} + protected void prepareSubAggs(long[] bucketOrdsToCollect) throws IOException {} /** * Build the results of the sub-aggregations of the buckets at each of @@ -186,7 +186,7 @@ protected void beforeBuildingBuckets(long[] ordsToCollect) throws IOException {} * array of ordinals */ protected final InternalAggregations[] buildSubAggsForBuckets(long[] bucketOrdsToCollect) throws IOException { - beforeBuildingBuckets(bucketOrdsToCollect); + prepareSubAggs(bucketOrdsToCollect); InternalAggregation[][] aggregations = new InternalAggregation[subAggregators.length][]; for (int i = 0; i < subAggregators.length; i++) { aggregations[i] = subAggregators[i].buildAggregations(bucketOrdsToCollect); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/DeferableBucketAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/DeferableBucketAggregator.java index 9e49d2d654654..a87bf6b0e477f 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/DeferableBucketAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/DeferableBucketAggregator.java @@ -21,8 +21,8 @@ import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; -import org.elasticsearch.search.aggregations.CardinalityUpperBound; import org.elasticsearch.search.aggregations.BucketCollector; +import org.elasticsearch.search.aggregations.CardinalityUpperBound; import org.elasticsearch.search.aggregations.MultiBucketCollector; import org.elasticsearch.search.internal.SearchContext; @@ -91,9 +91,9 @@ protected boolean shouldDefer(Aggregator aggregator) { } @Override - protected void beforeBuildingBuckets(long[] ordsToCollect) throws IOException { + protected final void prepareSubAggs(long[] bucketOrdsToCollect) throws IOException { if (recordingWrapper != null) { - recordingWrapper.prepareSelectedBuckets(ordsToCollect); + recordingWrapper.prepareSelectedBuckets(bucketOrdsToCollect); } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/DeferringBucketCollector.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/DeferringBucketCollector.java index bc6ab0b746fe1..4e489993da8e1 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/DeferringBucketCollector.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/DeferringBucketCollector.java @@ -116,12 +116,6 @@ public void preCollection() throws IOException { "Deferred collectors cannot be collected directly. They must be collected through the recording wrapper."); } - @Override - public void postCollection() throws IOException { - throw new IllegalStateException( - "Deferred collectors cannot be collected directly. They must be collected through the recording wrapper."); - } - @Override public Aggregator resolveSortPath(PathElement next, Iterator path) { return in.resolveSortPath(next, path); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregator.java index 2791e1edd72c7..07fa0393c5f14 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregator.java @@ -135,15 +135,11 @@ protected void doPreCollection() throws IOException { collectableSubAggregators = BucketCollector.NO_OP_COLLECTOR; } - @Override - protected void doPostCollection() throws IOException { - finishLeaf(); - } - @Override public InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws IOException { // Composite aggregator must be at the top of the aggregation tree assert owningBucketOrds.length == 1 && owningBucketOrds[0] == 0L; + finishLeaf(); if (deferredCollectors != NO_OP_COLLECTOR) { // Replay all documents that contain at least one top bucket (collected during the first pass). runDeferredCollections(); @@ -487,7 +483,6 @@ private void runDeferredCollections() throws IOException { collector.collect(docID); } } - deferredCollectors.postCollection(); } /** diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java index 74024c2a1aa8f..f481d30d8b0fd 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java @@ -111,11 +111,6 @@ protected void preGetSubLeafCollectors() throws IOException { processBufferedDocs(); } - @Override - protected void doPostCollection() throws IOException { - processBufferedDocs(); - } - private void processBufferedDocs() throws IOException { if (bufferingNestedLeafBucketCollector != null) { bufferingNestedLeafBucketCollector.processBufferedChildBuckets(); @@ -124,6 +119,7 @@ private void processBufferedDocs() throws IOException { @Override public InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws IOException { + processBufferedDocs(); return buildAggregationsForSingleBucket(owningBucketOrds, (owningBucketOrd, subAggregationResults) -> new InternalNested(name, bucketDocCount(owningBucketOrd), subAggregationResults, metadata())); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollector.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollector.java index bc581551b3c6f..96bbfa30ac7da 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollector.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollector.java @@ -124,15 +124,9 @@ public void preCollection() throws IOException { deferred.preCollection(); } - @Override - public void postCollection() throws IOException { - runDeferredAggs(); - } - - @Override public void prepareSelectedBuckets(long... selectedBuckets) throws IOException { - // no-op - deferred aggs processed in postCollection call + runDeferredAggs(); // TODO should we only prepare the selected buckets?! } private void runDeferredAggs() throws IOException { @@ -166,7 +160,6 @@ private void runDeferredAggs() throws IOException { // done with allDocs now, reclaim some memory circuitBreakerConsumer.accept(-12L * shardSize); } - deferred.postCollection(); } class PerParentBucketSamples { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java index 42c549f0ba839..740437a53d010 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java @@ -336,11 +336,12 @@ public void collect(int doc, long owningBucketOrd) throws IOException { } @Override - protected void doPostCollection() throws IOException { + public InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws IOException { if (mapping != null) { mapSegmentCountsToGlobalCounts(mapping); mapping = null; } + return super.buildAggregations(owningBucketOrds); } @Override diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/CardinalityAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/CardinalityAggregator.java index cef220f360e06..c97e1f2785f18 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/CardinalityAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/CardinalityAggregator.java @@ -146,7 +146,7 @@ private void postCollectLastCollector() throws IOException { } @Override - protected void doPostCollection() throws IOException { + protected void beforeBuildingResults(long[] ordsToCollect) throws IOException { postCollectLastCollector(); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/GlobalOrdCardinalityAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/GlobalOrdCardinalityAggregator.java index 8bd018f49cefe..916673c86e91c 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/GlobalOrdCardinalityAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/GlobalOrdCardinalityAggregator.java @@ -102,7 +102,7 @@ public void collect(int doc, long bucketOrd) throws IOException { } @Override - protected void doPostCollection() throws IOException { + protected void beforeBuildingResults(long[] ordsToCollect) throws IOException { counts = new HyperLogLogPlusPlusSparse(precision, bigArrays, visitedOrds.size()); try (LongArray hashes = bigArrays.newLongArray(maxOrd, false)) { try (BitArray allVisitedOrds = new BitArray(maxOrd, bigArrays)) { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/MetricsAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/MetricsAggregator.java index c704f0e1c7755..c94379d212561 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/MetricsAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/MetricsAggregator.java @@ -38,17 +38,24 @@ protected MetricsAggregator(String name, SearchContext context, Aggregator paren */ } + /** + * Called once before any calls to {@link #buildAggregation(long)} so the + * Aggregator can finish up any work it has to do. + */ + protected void beforeBuildingResults(long[] ordsToCollect) throws IOException {} + /** * Build an aggregation for data that has been collected into * {@code owningBucketOrd}. */ - public abstract InternalAggregation buildAggregation(long owningBucketOrd) throws IOException; + public abstract InternalAggregation buildAggregation(long ordToCollect) throws IOException; @Override - public final InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws IOException { - InternalAggregation[] results = new InternalAggregation[owningBucketOrds.length]; - for (int ordIdx = 0; ordIdx < owningBucketOrds.length; ordIdx++) { - results[ordIdx] = buildAggregation(owningBucketOrds[ordIdx]); + public final InternalAggregation[] buildAggregations(long[] ordsToCollect) throws IOException { + beforeBuildingResults(ordsToCollect); + InternalAggregation[] results = new InternalAggregation[ordsToCollect.length]; + for (int ordIdx = 0; ordIdx < ordsToCollect.length; ordIdx++) { + results[ordIdx] = buildAggregation(ordsToCollect[ordIdx]); } return results; } diff --git a/server/src/main/java/org/elasticsearch/search/profile/aggregation/AggregationTimingType.java b/server/src/main/java/org/elasticsearch/search/profile/aggregation/AggregationTimingType.java index 8a65ef2f72cb8..aa0c37485c2b2 100644 --- a/server/src/main/java/org/elasticsearch/search/profile/aggregation/AggregationTimingType.java +++ b/server/src/main/java/org/elasticsearch/search/profile/aggregation/AggregationTimingType.java @@ -25,7 +25,6 @@ public enum AggregationTimingType { INITIALIZE, BUILD_LEAF_COLLECTOR, COLLECT, - POST_COLLECTION, BUILD_AGGREGATION, REDUCE; diff --git a/server/src/main/java/org/elasticsearch/search/profile/aggregation/ProfilingAggregator.java b/server/src/main/java/org/elasticsearch/search/profile/aggregation/ProfilingAggregator.java index 1944904dfd11a..5e7cf82c2392b 100644 --- a/server/src/main/java/org/elasticsearch/search/profile/aggregation/ProfilingAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/profile/aggregation/ProfilingAggregator.java @@ -124,17 +124,6 @@ public void preCollection() throws IOException { profiler.pollLastElement(); } - @Override - public void postCollection() throws IOException { - Timer timer = profileBreakdown.getTimer(AggregationTimingType.POST_COLLECTION); - timer.start(); - try { - delegate.postCollection(); - } finally { - timer.stop(); - } - } - @Override public String toString() { return delegate.toString(); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/MultiBucketCollectorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/MultiBucketCollectorTests.java index bc8070d7ae40f..0d2a163b5187f 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/MultiBucketCollectorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/MultiBucketCollectorTests.java @@ -92,9 +92,6 @@ public ScoreMode scoreMode() { @Override public void preCollection() {} - - @Override - public void postCollection() {} } private static class TotalHitCountBucketCollector extends BucketCollector { @@ -122,9 +119,6 @@ public ScoreMode scoreMode() { @Override public void preCollection() {} - @Override - public void postCollection() {} - int getTotalHits() { return count; } @@ -158,9 +152,6 @@ public ScoreMode scoreMode() { @Override public void preCollection() {} - - @Override - public void postCollection() {} } public void testCollectionTerminatedExceptionHandling() throws IOException { diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/BestBucketsDeferringCollectorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/BestBucketsDeferringCollectorTests.java index 040c98d487fec..cc084b879e63e 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/BestBucketsDeferringCollectorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/BestBucketsDeferringCollectorTests.java @@ -79,7 +79,6 @@ public ScoreMode scoreMode() { collector.setDeferredCollector(Collections.singleton(bla(deferredCollectedDocIds))); collector.preCollection(); indexSearcher.search(termQuery, collector); - collector.postCollection(); collector.prepareSelectedBuckets(0); assertEquals(topDocs.scoreDocs.length, deferredCollectedDocIds.size()); @@ -93,7 +92,6 @@ public ScoreMode scoreMode() { collector.setDeferredCollector(Collections.singleton(bla(deferredCollectedDocIds))); collector.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), collector); - collector.postCollection(); collector.prepareSelectedBuckets(0); assertEquals(topDocs.scoreDocs.length, deferredCollectedDocIds.size()); @@ -121,11 +119,6 @@ public void preCollection() throws IOException { } - @Override - public void postCollection() throws IOException { - - } - @Override public ScoreMode scoreMode() { return ScoreMode.COMPLETE_NO_SCORES; diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalAggregatorTests.java index d1a728383859c..87e2454ab3afd 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalAggregatorTests.java @@ -80,7 +80,6 @@ private void testCase(CheckedConsumer buildIndex GlobalAggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); InternalGlobal result = (InternalGlobal) aggregator.buildTopLevel(); verify.accept(result, (InternalMin) result.getAggregations().asMap().get("in_global")); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/MergingBucketsDeferringCollectorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/MergingBucketsDeferringCollectorTests.java index 04a6c48e86009..787e6d9e88ba6 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/MergingBucketsDeferringCollectorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/MergingBucketsDeferringCollectorTests.java @@ -130,16 +130,12 @@ public ScoreMode scoreMode() { @Override public void preCollection() throws IOException {} - @Override - public void postCollection() throws IOException {} - @Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx) throws IOException { LeafBucketCollector delegate = deferringCollector.getLeafCollector(ctx); return leafCollector.apply(deferringCollector, delegate); } }); - deferringCollector.postCollection(); verify.accept(deferringCollector, finalCollector); } } @@ -165,8 +161,5 @@ public void collect(int doc, long owningBucketOrd) throws IOException { @Override public void preCollection() throws IOException {} - - @Override - public void postCollection() throws IOException {} } } diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java index c8dc51e6d5a79..b022d40bca701 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java @@ -298,7 +298,6 @@ private void testCase(Query query, int precision, GeoBoundingBox geoBoundingBox, Aggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(query, aggregator); - aggregator.postCollection(); verify.accept((InternalGeoGrid) aggregator.buildTopLevel()); indexReader.close(); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollectorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollectorTests.java index 76ab7ee53ac52..22c122b770099 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollectorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollectorTests.java @@ -74,7 +74,6 @@ public void testReplay() throws Exception { collector.setDeferredCollector(Collections.singleton(testCollector(deferredCollectedDocIds))); collector.preCollection(); indexSearcher.search(termQuery, collector); - collector.postCollection(); collector.prepareSelectedBuckets(0); assertEquals(topDocs.scoreDocs.length, deferredCollectedDocIds.size()); @@ -103,11 +102,6 @@ public void preCollection() throws IOException { } - @Override - public void postCollection() throws IOException { - - } - @Override public ScoreMode scoreMode() { return ScoreMode.COMPLETE_NO_SCORES; diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java index 78e8ca6f68147..ca7c180417202 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java @@ -270,7 +270,6 @@ public void testUnmapped() throws Exception { Aggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType1, fieldType2); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); RareTerms result = (RareTerms) aggregator.buildTopLevel(); assertEquals("_name", result.getName()); assertEquals(0, result.getBuckets().size()); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorTests.java index 7187e25a7266b..0f6c8b9221141 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorTests.java @@ -255,7 +255,6 @@ public void testSimple() throws Exception { TermsAggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); Terms result = reduce(aggregator); assertEquals(5, result.getBuckets().size()); assertEquals("", result.getBuckets().get(0).getKeyAsString()); @@ -324,7 +323,6 @@ public void testStringIncludeExclude() throws Exception { TermsAggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); Terms result = reduce(aggregator); assertEquals(10, result.getBuckets().size()); assertEquals("val000", result.getBuckets().get(0).getKeyAsString()); @@ -359,7 +357,6 @@ public void testStringIncludeExclude() throws Exception { aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType2); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); result = reduce(aggregator); assertEquals(5, result.getBuckets().size()); assertEquals("val001", result.getBuckets().get(0).getKeyAsString()); @@ -383,7 +380,6 @@ public void testStringIncludeExclude() throws Exception { aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); result = reduce(aggregator); assertEquals(8, result.getBuckets().size()); assertEquals("val002", result.getBuckets().get(0).getKeyAsString()); @@ -412,7 +408,6 @@ public void testStringIncludeExclude() throws Exception { aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); result = reduce(aggregator); assertEquals(2, result.getBuckets().size()); assertEquals("val010", result.getBuckets().get(0).getKeyAsString()); @@ -429,7 +424,6 @@ public void testStringIncludeExclude() throws Exception { aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); result = reduce(aggregator); assertEquals(2, result.getBuckets().size()); assertEquals("val000", result.getBuckets().get(0).getKeyAsString()); @@ -447,7 +441,6 @@ public void testStringIncludeExclude() throws Exception { aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); result = reduce(aggregator); assertEquals(2, result.getBuckets().size()); assertEquals("val000", result.getBuckets().get(0).getKeyAsString()); @@ -502,7 +495,6 @@ public void testNumericIncludeExclude() throws Exception { TermsAggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); Terms result = reduce(aggregator); assertEquals(2, result.getBuckets().size()); assertEquals(0L, result.getBuckets().get(0).getKey()); @@ -519,7 +511,6 @@ public void testNumericIncludeExclude() throws Exception { aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); result = reduce(aggregator); assertEquals(4, result.getBuckets().size()); assertEquals(1L, result.getBuckets().get(0).getKey()); @@ -542,7 +533,6 @@ public void testNumericIncludeExclude() throws Exception { aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); result = reduce(aggregator); assertEquals(2, result.getBuckets().size()); assertEquals(0.0, result.getBuckets().get(0).getKey()); @@ -559,7 +549,6 @@ public void testNumericIncludeExclude() throws Exception { aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); result = reduce(aggregator); assertEquals(4, result.getBuckets().size()); assertEquals(1.0, result.getBuckets().get(0).getKey()); @@ -725,7 +714,6 @@ private void termsAggregator(ValueType valueType, MappedFieldType fieldType, Aggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); Terms result = reduce(aggregator); assertEquals(size, result.getBuckets().size()); for (int i = 0; i < size; i++) { @@ -751,7 +739,6 @@ private void termsAggregator(ValueType valueType, MappedFieldType fieldType, aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType, filterFieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); result = ((Filter) reduce(aggregator)).getAggregations().get("_name2"); int expectedFilteredCounts = 0; for (Integer count : filteredCounts.values()) { @@ -824,7 +811,6 @@ private void termsAggregatorWithNestedMaxAgg(ValueType valueType, MappedFiel Aggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType, fieldType2); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); Terms result = reduce(aggregator); assertEquals(size, result.getBuckets().size()); for (int i = 0; i < size; i++) { @@ -853,7 +839,6 @@ public void testEmpty() throws Exception { Aggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType1); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); Terms result = reduce(aggregator); assertEquals("_name", result.getName()); assertEquals(0, result.getBuckets().size()); @@ -863,7 +848,6 @@ public void testEmpty() throws Exception { aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType2); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); result = reduce(aggregator); assertEquals("_name", result.getName()); assertEquals(0, result.getBuckets().size()); @@ -873,7 +857,6 @@ public void testEmpty() throws Exception { aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType3); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); result = reduce(aggregator); assertEquals("_name", result.getName()); assertEquals(0, result.getBuckets().size()); @@ -896,7 +879,6 @@ public void testUnmapped() throws Exception { Aggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, (MappedFieldType) null); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); Terms result = reduce(aggregator); assertEquals("_name", result.getName()); assertEquals(0, result.getBuckets().size()); @@ -932,7 +914,6 @@ public void testUnmappedWithMissing() throws Exception { Aggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType1); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); Terms result = reduce(aggregator); assertEquals("_name", result.getName()); assertEquals(1, result.getBuckets().size()); @@ -1004,7 +985,6 @@ public void testIpField() throws Exception { Aggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); Terms result = reduce(aggregator); assertEquals("_name", result.getName()); assertEquals(1, result.getBuckets().size()); @@ -1052,7 +1032,6 @@ public void testNestedTermsAgg() throws Exception { Aggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType1, fieldType2); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); Terms result = reduce(aggregator); assertEquals(3, result.getBuckets().size()); assertEquals("a", result.getBuckets().get(0).getKeyAsString()); @@ -1447,7 +1426,6 @@ private InternalAggregation buildInternalAggregation(TermsAggregationBuilder bui TermsAggregator aggregator = createAggregator(builder, searcher, fieldType); aggregator.preCollection(); searcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); return aggregator.buildTopLevel(); } diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgAggregatorTests.java index ece0012e093fb..212babaa913f0 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgAggregatorTests.java @@ -286,7 +286,6 @@ public void testSingleValuedFieldPartiallyUnmapped() throws IOException { AvgAggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); InternalAvg avg = (InternalAvg) aggregator.buildAggregation(0L); @@ -531,7 +530,6 @@ public void testOrderByEmptyAggregation() throws IOException { TermsAggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); Terms terms = (Terms) aggregator.buildTopLevel(); assertNotNull(terms); @@ -603,7 +601,6 @@ public void testCacheAggregation() throws IOException { AvgAggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); InternalAvg avg = (InternalAvg) aggregator.buildAggregation(0L); @@ -649,7 +646,6 @@ public void testScriptCaching() throws IOException { AvgAggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); InternalAvg avg = (InternalAvg) aggregator.buildAggregation(0L); @@ -667,7 +663,6 @@ public void testScriptCaching() throws IOException { aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType); aggregator.preCollection(); indexSearcher.search(new MatchAllDocsQuery(), aggregator); - aggregator.postCollection(); avg = (InternalAvg) aggregator.buildAggregation(0L); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesAggregatorTests.java index 6f1196e7cd2c5..8a0ea815e72b2 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesAggregatorTests.java @@ -214,7 +214,6 @@ private void testCase(Query query, CheckedConsumer A searchAndReduc a.preCollection(); Weight weight = subSearcher.createWeight(rewritten, ScoreMode.COMPLETE, 1f); subSearcher.search(weight, a); - a.postCollection(); aggs.add(a.buildTopLevel()); } } else { root.preCollection(); searcher.search(rewritten, root); - root.postCollection(); aggs.add(root.buildTopLevel()); } diff --git a/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/aggregations/metrics/HDRPreAggregatedPercentilesAggregatorTests.java b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/aggregations/metrics/HDRPreAggregatedPercentilesAggregatorTests.java index 6792eec5d928d..c6bb96fc80aec 100644 --- a/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/aggregations/metrics/HDRPreAggregatedPercentilesAggregatorTests.java +++ b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/aggregations/metrics/HDRPreAggregatedPercentilesAggregatorTests.java @@ -152,7 +152,6 @@ private void testCase(Query query, CheckedConsumer) aggregator.buildTopLevel()); indexReader.close();