jpountz commented on a change in pull request #1937: URL: https://github.com/apache/lucene-solr/pull/1937#discussion_r498523124
########## File path: lucene/core/src/java/org/apache/lucene/search/ConjunctionDISI.java ########## @@ -227,6 +236,7 @@ private int doNext(int doc) throws IOException { @Override public int advance(int target) throws IOException { + assertItersOnSameDoc(); Review comment: can we avoid iterating over all sub iterators unless assertions are enabled? ########## File path: lucene/core/src/java/org/apache/lucene/search/ConjunctionDISI.java ########## @@ -140,6 +141,13 @@ private static void addTwoPhaseIterator(TwoPhaseIterator twoPhaseIter, List<DocI private static DocIdSetIterator createConjunction( List<DocIdSetIterator> allIterators, List<TwoPhaseIterator> twoPhaseIterators) { + + // assert that all sub-iterators are on the same doc ID + int curDoc = allIterators.size() > 0 ? allIterators.get(0).docID() : twoPhaseIterators.get(0).approximation.docID(); + boolean iteratorsOnTheSameDoc = allIterators.stream().allMatch(it -> it.docID() == curDoc); + iteratorsOnTheSameDoc = iteratorsOnTheSameDoc && twoPhaseIterators.stream().allMatch(it -> it.approximation().docID() == curDoc); + assert iteratorsOnTheSameDoc : "Sub-iterators of ConjunctionDISI are not the same document!"; Review comment: let's make it an IllegalArgumentException? ########## File path: lucene/core/src/java/org/apache/lucene/search/ConjunctionDISI.java ########## @@ -140,6 +141,13 @@ private static void addTwoPhaseIterator(TwoPhaseIterator twoPhaseIter, List<DocI private static DocIdSetIterator createConjunction( List<DocIdSetIterator> allIterators, List<TwoPhaseIterator> twoPhaseIterators) { + + // assert that all sub-iterators are on the same doc ID Review comment: this is the invariant between iterations indeed ---------------------------------------------------------------- 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 --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org