mikemccand commented on a change in pull request #923: LUCENE-8988: Introduce 
Global Feature Based Early Termination For Sorted Fields
URL: https://github.com/apache/lucene-solr/pull/923#discussion_r335019302
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java
 ##########
 @@ -130,8 +130,25 @@ public void setScorer(Scorable scorer) throws IOException 
{
         public void collect(int doc) throws IOException {
           ++totalHits;
           hitsThresholdChecker.incrementHitCount();
-          if (queueFull) {
-            if (collectedAllCompetitiveHits || reverseMul * 
comparator.compareBottom(doc) <= 0) {
+
+          Object currentValue = null;
+
+          if (fieldValueChecker != null) {
+            try {
+              currentValue = comparator.getDocValue(doc);
+            } catch (UnsupportedOperationException e) {
+              fieldValueChecker.disableGlobalHitCheck();
+            }
+          }
+
+          boolean isHitGloballyCompetitive = 
isHitGloballyCompetitive(currentValue, doc);
+
+          // There is a potential race condition here -- the hit may no longer 
be competitive between the
+          // two checks. However, the tradeoff is performing the global check 
twice -- which is expensive.
+          // Hence, the worst we can end up is an extra non competitive hit
+          if (queueFull || (isHitGloballyCompetitive == false)) {
 
 Review comment:
   Don't need `( .. )` around the `(isHitGloballyCompetitive == false)`.

----------------------------------------------------------------
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: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to