Skip to content

Commit

Permalink
tidy up post collection.
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvg committed Aug 10, 2023
1 parent 4023454 commit dc80bd8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.elasticsearch.common.util.concurrent.FutureUtils;
import org.elasticsearch.core.Releasable;
import org.elasticsearch.lucene.util.CombinedBitSet;
import org.elasticsearch.search.aggregations.BucketCollector;
import org.elasticsearch.search.dfs.AggregatedDfs;
import org.elasticsearch.search.profile.Timer;
import org.elasticsearch.search.profile.query.InternalProfileCollector;
Expand Down Expand Up @@ -471,11 +470,8 @@ public void search(List<LeafReaderContext> leaves, Weight weight, Collector coll

private void doAggregationPostCollection(Collector collector) throws IOException {
if (collector instanceof QueryPhaseCollector queryPhaseCollector) {
if (queryPhaseCollector.getAggsCollector() instanceof BucketCollector.BucketCollectorWrapper aggsCollector) {
aggsCollector.bucketCollector().postCollection();
}
}
if (collector instanceof InternalProfileCollector profilerCollector) {
queryPhaseCollector.doPostCollection();
} else if (collector instanceof InternalProfileCollector profilerCollector) {
profilerCollector.doPostCollection();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ public void doPostCollection() throws IOException {
if (wrappedCollector instanceof InternalProfileCollector profileCollector) {
profileCollector.doPostCollection();
} else if (wrappedCollector instanceof QueryPhaseCollector queryPhaseCollector) {
if (queryPhaseCollector.getAggsCollector() instanceof BucketCollector.BucketCollectorWrapper aggsCollector) {
aggsCollector.bucketCollector().postCollection();
} else if (queryPhaseCollector.getAggsCollector() instanceof InternalProfileCollector profileCollector) {
profileCollector.doPostCollection();
}
queryPhaseCollector.doPostCollection();
} else if (wrappedCollector instanceof BucketCollector.BucketCollectorWrapper aggsCollector) {
aggsCollector.bucketCollector().postCollection();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.lucene.search.Weight;
import org.apache.lucene.util.Bits;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.search.aggregations.BucketCollector;
import org.elasticsearch.search.profile.query.InternalProfileCollector;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -458,7 +460,11 @@ boolean isTerminatedAfter() {
}
}

public Collector getAggsCollector() {
return aggsCollector;
public void doPostCollection() throws IOException {
if (aggsCollector instanceof BucketCollector.BucketCollectorWrapper bucketCollectorWrapper) {
bucketCollectorWrapper.bucketCollector().postCollection();
} else if (aggsCollector instanceof InternalProfileCollector profileCollector) {
profileCollector.doPostCollection();
}
}
}

0 comments on commit dc80bd8

Please sign in to comment.