Check accepts docs before MatchDocIdSet#matchDoc(int)

We currently ask `MatchDocIdSet#matchDoc(int)` before consulting
the accept docs. This can also have a negative performance impact
since `matchDoc(int)` calls might be way more expensive than
acceptDocs calls.

Closes #6234
This commit is contained in:
Simon Willnauer 2014-05-19 17:17:55 +02:00
parent d1589b3815
commit 579a79d1ac
1 changed files with 5 additions and 5 deletions

View File

@ -72,7 +72,7 @@ public abstract class MatchDocIdSet extends DocIdSet implements Bits {
return maxDoc;
}
class NoAcceptDocsIterator extends DocIdSetIterator {
final class NoAcceptDocsIterator extends DocIdSetIterator {
private final int maxDoc;
private int doc = -1;
@ -114,7 +114,7 @@ public abstract class MatchDocIdSet extends DocIdSet implements Bits {
}
class FixedBitSetIterator extends FilteredDocIdSetIterator {
final class FixedBitSetIterator extends FilteredDocIdSetIterator {
FixedBitSetIterator(DocIdSetIterator innerIter) {
super(innerIter);
@ -126,7 +126,7 @@ public abstract class MatchDocIdSet extends DocIdSet implements Bits {
}
}
class BothIterator extends DocIdSetIterator {
final class BothIterator extends DocIdSetIterator {
private final int maxDoc;
private final Bits acceptDocs;
private int doc = -1;
@ -148,14 +148,14 @@ public abstract class MatchDocIdSet extends DocIdSet implements Bits {
if (doc >= maxDoc) {
return doc = NO_MORE_DOCS;
}
} while (!(matchDoc(doc) && acceptDocs.get(doc)));
} while (!(acceptDocs.get(doc) && matchDoc(doc)));
return doc;
}
@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;
}
}