From 66ab542f2fa6d45f5bcb01f3b1d069386d8c5cbe Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Mon, 21 Nov 2011 09:46:30 +0000 Subject: [PATCH] LUCENE-3448: Make optimization for OpenBitSetIterator correctly exhaust iterator git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1204416 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/src/java/org/apache/lucene/util/FixedBitSet.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lucene/src/java/org/apache/lucene/util/FixedBitSet.java b/lucene/src/java/org/apache/lucene/util/FixedBitSet.java index 6a2ea4079b8..ca23078e775 100644 --- a/lucene/src/java/org/apache/lucene/util/FixedBitSet.java +++ b/lucene/src/java/org/apache/lucene/util/FixedBitSet.java @@ -192,6 +192,9 @@ public final class FixedBitSet extends DocIdSet implements Bits { if (iter instanceof OpenBitSetIterator && iter.docID() == -1) { final OpenBitSetIterator obs = (OpenBitSetIterator) iter; or(obs.arr, obs.words); + // advance after last doc that would be accepted if standard + // iteration is used (to exhaust it): + obs.advance(numBits); } else { int doc; while ((doc = iter.nextDoc()) < numBits) { @@ -219,6 +222,9 @@ public final class FixedBitSet extends DocIdSet implements Bits { if (iter instanceof OpenBitSetIterator && iter.docID() == -1) { final OpenBitSetIterator obs = (OpenBitSetIterator) iter; and(obs.arr, obs.words); + // advance after last doc that would be accepted if standard + // iteration is used (to exhaust it): + obs.advance(numBits); } else { if (numBits == 0) return; int disiDoc, bitSetDoc = nextSetBit(0); @@ -255,6 +261,9 @@ public final class FixedBitSet extends DocIdSet implements Bits { if (iter instanceof OpenBitSetIterator && iter.docID() == -1) { final OpenBitSetIterator obs = (OpenBitSetIterator) iter; andNot(obs.arr, obs.words); + // advance after last doc that would be accepted if standard + // iteration is used (to exhaust it): + obs.advance(numBits); } else { int doc; while ((doc = iter.nextDoc()) < numBits) {