romseygeek commented on code in PR #13315:
URL: https://github.com/apache/lucene/pull/13315#discussion_r1608372668


##########
lucene/core/src/java/org/apache/lucene/search/DisjunctionMatchesIterator.java:
##########
@@ -194,6 +194,15 @@ private DisjunctionMatchesIterator(List<MatchesIterator> 
matches) throws IOExcep
         new PriorityQueue<MatchesIterator>(matches.size()) {
           @Override
           protected boolean lessThan(MatchesIterator a, MatchesIterator b) {
+            if (a.startPosition() == -1 && b.startPosition() == -1) {
+              try {
+                return a.startOffset() < b.startOffset()
+                    || (a.startOffset() == b.startOffset() && a.endOffset() < 
b.endOffset())
+                    || (a.startOffset() == b.startOffset() && a.endOffset() == 
b.endOffset());
+              } catch (IOException e) {
+                throw new IllegalArgumentException("Failed to retrieve term 
offset", e);
+              }
+            }

Review Comment:
   It's because the work of loading positions is always done in `next()`, so 
there's no IO involved when calling `startPosition` or `endPosition`.  But we 
only load offsets when specifically asked, so IO may be involved when calling 
those methods.  It does look a bit funky though, I agree!



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to