mikemccand 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_r320956707
 
 

 ##########
 File path: 
lucene/core/src/java/org/apache/lucene/search/TopScoreDocCollector.java
 ##########
 @@ -191,32 +195,64 @@ public static TopScoreDocCollector create(int numHits, 
int totalHitsThreshold) {
    * objects.
    */
   public static TopScoreDocCollector create(int numHits, ScoreDoc after, int 
totalHitsThreshold) {
+    return create(numHits, after, 
HitsThresholdChecker.create(totalHitsThreshold));
+  }
+
+  static TopScoreDocCollector create(int numHits, ScoreDoc after, 
HitsThresholdChecker hitsThresholdChecker) {
 
     if (numHits <= 0) {
       throw new IllegalArgumentException("numHits must be > 0; please use 
TotalHitCountCollector if you just need the total hit count");
     }
 
-    if (totalHitsThreshold < 0) {
-      throw new IllegalArgumentException("totalHitsThreshold must be >= 0, got 
" + totalHitsThreshold);
+    if (hitsThresholdChecker == null) {
+      throw new IllegalArgumentException("hitsThresholdChecker must be non 
null");
     }
 
     if (after == null) {
-      return new SimpleTopScoreDocCollector(numHits, totalHitsThreshold);
+      return new SimpleTopScoreDocCollector(numHits, hitsThresholdChecker);
     } else {
-      return new PagingTopScoreDocCollector(numHits, after, 
totalHitsThreshold);
+      return new PagingTopScoreDocCollector(numHits, after, 
hitsThresholdChecker);
     }
   }
 
-  final int totalHitsThreshold;
+  /**
+   * Create a CollectorManager which uses a shared hit counter to maintain 
number of hits
+   */
+  public static CollectorManager<TopScoreDocCollector, TopDocs> 
createSharedManager(int numHits, FieldDoc after,
+                                                                               
       int totalHitsThreshold) {
+    return new CollectorManager<>() {
+
+      private final HitsThresholdChecker hitsThresholdChecker = 
HitsThresholdChecker.createShared(totalHitsThreshold);
 
 Review comment:
   Same here.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to