You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/10/01 21:30:55 UTC

[GitHub] [lucene-solr] jpountz commented on a change in pull request #1937: LUCENE-9541 ConjunctionDISI sub-iterators check

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



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