Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: bowenlan-amzn <[email protected]>
  • Loading branch information
bowenlan-amzn committed Jun 7, 2024
1 parent d4a3a5d commit 29f0841
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private Collector pickCollector(LeafReaderContext ctx) throws IOException {
final long maxOrd = ordinalValues.getValueCount();
if (maxOrd == 0) {
emptyCollectorsUsed++;
collector = new EmptyCollector();
return new EmptyCollector();
} else {
final long ordinalsMemoryUsage = OrdinalsCollector.memoryOverhead(maxOrd);
final long countsMemoryUsage = HyperLogLogPlusPlus.memoryUsage(precision);
Expand All @@ -158,14 +158,17 @@ private Collector pickCollector(LeafReaderContext ctx) throws IOException {
ordinalsCollectorsOverheadTooHigh++;
}
}
} else {
}

if (collector == null) { // not able to build an OrdinalsCollector
stringHashingCollectorsUsed++;
collector = new DirectCollector(counts, MurmurHash3Values.hash(valuesSource.bytesValues(ctx)));
}

if (parent == null && subAggregators.length == 0 && valuesSourceConfig.missing() == null && valuesSourceConfig.script() == null) {
Terms terms = ctx.reader().terms(valuesSourceConfig.fieldContext().field());
if (terms != null) {
// Specify TOP_DOCS score mode to use competitive iterator from collector
Weight weight = context.searcher().createWeight(context.searcher().rewrite(context.query()), ScoreMode.TOP_DOCS, 1f);
Bits liveDocs = ctx.reader().getLiveDocs();
BulkScorer scorer = weight.bulkScorer(ctx);
Expand All @@ -175,7 +178,19 @@ private Collector pickCollector(LeafReaderContext ctx) throws IOException {
Releasables.close(collector);
logger.debug("Dynamic pruning shard {} segment {}", context.indexShard().shardId(), ctx.ord);
dynamicPruningSegments++;
throw new CollectionTerminatedException();
// return a no-op collector to not breaking profile results
return new Collector() {
@Override
public void close() {}

@Override
public void postCollect() throws IOException {}

@Override
public void collect(int doc, long owningBucketOrd) throws IOException {
throw new CollectionTerminatedException();
}
};
}
}

Expand Down

0 comments on commit 29f0841

Please sign in to comment.