Skip to content

Commit ccf11fb

Browse files
committed
iter
Signed-off-by: expani <[email protected]>
1 parent 1757058 commit ccf11fb

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

server/src/main/java/org/opensearch/search/internal/ContextIndexSearcher.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,10 @@ public void search(Query query, Collector collector) throws IOException {
263263
// search(LeafReaderContextPartition[] partitions, Weight weight, Collector collector)
264264
query = collector.scoreMode().needsScores() ? rewrite(query) : rewrite(new ConstantScoreQuery(query));
265265
Weight weight = createWeight(query, collector.scoreMode(), 1);
266-
List<LeafReaderContext> leaves = getLeafContexts();
267-
if (leaves != null && !leaves.isEmpty()) {
268-
search(
269-
leaves.stream().map(LeafReaderContextPartition::createForEntireSegment).toArray(LeafReaderContextPartition[]::new),
270-
weight,
271-
collector
272-
);
273-
} else {
274-
searchContext.bucketCollectorProcessor().processPostCollection(collector);
275-
}
266+
LeafReaderContextPartition[] partitions = (getLeafContexts() == null)
267+
? new LeafReaderContextPartition[0]
268+
: getLeafContexts().stream().map(LeafReaderContextPartition::createForEntireSegment).toArray(LeafReaderContextPartition[]::new);
269+
search(partitions, weight, collector);
276270
}
277271

278272
public void search(
@@ -311,7 +305,7 @@ protected void search(LeafReaderContextPartition[] partitions, Weight weight, Co
311305
searchLeaf(partition.ctx, partition.minDocId, partition.maxDocId, weight, collector);
312306
}
313307
}
314-
// FIXME : Make this a responsibility for the callers rather than implicitly getting it done.
308+
// TODO : Make this a responsibility for the callers rather than implicitly getting it done here ?
315309
searchContext.bucketCollectorProcessor().processPostCollection(collector);
316310
} catch (Throwable t) {
317311
searchContext.indexShard().getSearchOperationListener().onFailedSliceExecution(searchContext);

0 commit comments

Comments
 (0)