jpountz commented on a change in pull request #823: LUCENE-8939: Introduce 
Shared Count Early Termination In Parallel Search
URL: https://github.com/apache/lucene-solr/pull/823#discussion_r320004946
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
 ##########
 @@ -467,9 +467,19 @@ public TopDocs searchAfter(ScoreDoc after, Query query, 
int numHits) throws IOEx
 
     final CollectorManager<TopScoreDocCollector, TopDocs> manager = new 
CollectorManager<TopScoreDocCollector, TopDocs>() {
 
+      private HitsThresholdChecker hitsThresholdChecker;
       @Override
       public TopScoreDocCollector newCollector() throws IOException {
-        return TopScoreDocCollector.create(cappedNumHits, after, 
TOTAL_HITS_THRESHOLD);
+
+        if (hitsThresholdChecker == null) {
+          if (executor == null || leafSlices.length <= 1) {
+            hitsThresholdChecker = 
HitsThresholdChecker.create(TOTAL_HITS_THRESHOLD);
+          } else {
+            hitsThresholdChecker = 
HitsThresholdChecker.createShared(TOTAL_HITS_THRESHOLD);
+          }
+        }
 
 Review comment:
   can we create it eagerly instead of lazily?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to