You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2015/02/19 16:43:35 UTC
svn commit: r1660916 - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/core/ lucene/core/src/java/org/apache/lucene/search/
lucene/test-framework/
lucene/test-framework/src/java/org/apache/lucene/search/
Author: jpountz
Date: Thu Feb 19 15:43:34 2015
New Revision: 1660916
URL: http://svn.apache.org/r1660916
Log:
LUCENE-6261: TwoPhaseDocIdSetIterator.matches() should be called at most once per doc ID.
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/lucene/ (props changed)
lucene/dev/branches/branch_5x/lucene/core/ (props changed)
lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TwoPhaseDocIdSetIterator.java
lucene/dev/branches/branch_5x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java
Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TwoPhaseDocIdSetIterator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TwoPhaseDocIdSetIterator.java?rev=1660916&r1=1660915&r2=1660916&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TwoPhaseDocIdSetIterator.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TwoPhaseDocIdSetIterator.java Thu Feb 19 15:43:34 2015
@@ -73,9 +73,9 @@ public abstract class TwoPhaseDocIdSetIt
public abstract DocIdSetIterator approximation();
/** Return whether the current doc ID that the iterator is on matches. This
- * method should only be called when the iterator is positionned, ie. not
+ * method should only be called when the iterator is positionned -- ie. not
* when {@link DocIdSetIterator#docID()} is {@code -1} or
- * {@link DocIdSetIterator#NO_MORE_DOCS}. */
+ * {@link DocIdSetIterator#NO_MORE_DOCS} -- and at most once. */
public abstract boolean matches() throws IOException;
}
Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java?rev=1660916&r1=1660915&r2=1660916&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java Thu Feb 19 15:43:34 2015
@@ -188,6 +188,7 @@ public class RandomApproximationQuery ex
private final DocIdSetIterator disi;
private final RandomApproximation approximation;
+ private int lastDoc = -1;
RandomTwoPhaseView(Random random, DocIdSetIterator disi) {
this.disi = disi;
@@ -201,7 +202,14 @@ public class RandomApproximationQuery ex
@Override
public boolean matches() throws IOException {
- return approximation.doc == disi.docID();
+ if (approximation.docID() == -1 || approximation.docID() == DocIdSetIterator.NO_MORE_DOCS) {
+ throw new AssertionError("matches() should not be called on doc ID " + approximation.doc);
+ }
+ if (lastDoc == approximation.docID()) {
+ throw new AssertionError("matches() has been called twice on doc ID " + approximation.doc);
+ }
+ lastDoc = approximation.docID();
+ return approximation.docID() == disi.docID();
}
}