You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by GitBox <gi...@apache.org> on 2019/07/01 12:43:21 UTC

[GitHub] [lucene-solr] jpountz commented on a change in pull request #734: LUCENE-8857: Introduce Custom Tiebreakers in TopDocs#merge

jpountz commented on a change in pull request #734: LUCENE-8857: Introduce Custom Tiebreakers in TopDocs#merge
URL: https://github.com/apache/lucene-solr/pull/734#discussion_r299011695
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/search/TopDocs.java
 ##########
 @@ -276,12 +298,16 @@ private static TopDocs mergeAux(Sort sort, int start, int size, TopDocs[] shardH
         assert queue.size() > 0;
         ShardRef ref = queue.top();
         final ScoreDoc hit = shardHits[ref.shardIndex].scoreDocs[ref.hitIndex++];
-        if (setShardIndex) {
-          // caller asked us to record shardIndex (index of the TopDocs array) this hit is coming from:
-          hit.shardIndex = ref.shardIndex;
-        } else if (hit.shardIndex == -1) {
-          throw new IllegalArgumentException("setShardIndex is false but TopDocs[" + ref.shardIndex + "].scoreDocs[" + (ref.hitIndex-1) + "] is not set");
-        }
+
+        // Irrespective of whether we use shard indices for tie breaking or not, we check for consistent
+        // order in shard indices to defend against potential bugs
+        if (hitUpto > 0) {
+          if (unsetShardIndex != (hit.shardIndex == -1)) {
+            throw new IllegalArgumentException("Inconsistent order of shard indices");
+          }
+      }
+
+      unsetShardIndex |= hit.shardIndex == -1;
 
 Review comment:
   it looks like there is an indentation issue on the above 3 lines?

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


With regards,
Apache Git Services

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