Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-6022: DocValuesDocIdSet checks live docs before doc values.

Adrien Grand62ed868f2a59
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 8b6a4fa2d8f..23579c419b4 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -243,6 +243,9 @@ Optimizations
* LUCENE-5983: CachingWrapperFilter now uses a new DocIdSet implementation
called RoaringDocIdSet instead of WAH8DocIdSet. (Adrien Grand)
+* LUCENE-6022: DocValuesDocIdSet checks live docs before doc values.
+ (Adrien Grand)
+
Build
* LUCENE-5909: Smoke tester now has better command line parsing and
diff --git a/lucene/core/src/java/org/apache/lucene/search/DocValuesDocIdSet.java b/lucene/core/src/java/org/apache/lucene/search/DocValuesDocIdSet.java
index 591bdfc6786..cefcd0dc680 100644
--- a/lucene/core/src/java/org/apache/lucene/search/DocValuesDocIdSet.java
+++ b/lucene/core/src/java/org/apache/lucene/search/DocValuesDocIdSet.java
@@ -27,8 +27,7 @@ import org.apache.lucene.util.FixedBitSet;
* of its iterator is very stupid and slow if the implementation of the
* {@link #matchDoc} method is not optimized, as iterators simply increment
* the document id until {@code matchDoc(int)} returns true. Because of this
- * {@code matchDoc(int)} must be as fast as possible and in no case do any
- * I/O.
+ * {@code matchDoc(int)} must be as fast as possible.
* @lucene.internal
*/
public abstract class DocValuesDocIdSet extends DocIdSet {
@@ -66,7 +65,7 @@ public abstract class DocValuesDocIdSet extends DocIdSet {
} : new Bits() {
@Override
public boolean get(int docid) {
- return matchDoc(docid) && acceptDocs.get(docid);
+ return acceptDocs.get(docid) && matchDoc(docid);
}
@Override
@@ -135,19 +134,13 @@ public abstract class DocValuesDocIdSet extends DocIdSet {
@Override
public int nextDoc() {
- do {
- doc++;
- if (doc >= maxDoc) {
- return doc = NO_MORE_DOCS;
- }
- } while (!(matchDoc(doc) && acceptDocs.get(doc)));
- return doc;
+ return advance(doc + 1);
}
@Override
public int advance(int target) {
for(doc=target; doc<maxDoc; doc++) {
- if (matchDoc(doc) && acceptDocs.get(doc)) {
+ if (acceptDocs.get(doc) && matchDoc(doc)) {
return doc;
}
}