From 7e02f0fb4b1589f00a5cffe0155293043ca96b5f Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 15 Feb 2013 00:25:49 +0000 Subject: [PATCH] nuke these nocommits by using openbitset git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4765@1446411 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/codecs/DocValuesConsumer.java | 22 ++++++++----------- .../org/apache/lucene/index/CheckIndex.java | 7 +++--- .../asserting/AssertingDocValuesFormat.java | 6 ++--- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java index a124866d48f..1db957b2c60 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java @@ -39,7 +39,7 @@ import org.apache.lucene.index.TermsEnum; import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.FixedBitSet; +import org.apache.lucene.util.OpenBitSet; /** * Abstract API that consumes numeric, binary and @@ -271,7 +271,7 @@ public abstract class DocValuesConsumer implements Closeable { if (liveDocs == null) { liveTerms[sub] = new SortedDocValuesTermsEnum(dv); } else { - FixedBitSet bitset = new FixedBitSet(dv.getValueCount()); + OpenBitSet bitset = new OpenBitSet(dv.getValueCount()); for (int i = 0; i < reader.maxDoc(); i++) { if (liveDocs.get(i)) { bitset.set(dv.getOrd(i)); @@ -403,17 +403,13 @@ public abstract class DocValuesConsumer implements Closeable { if (liveDocs == null) { liveTerms[sub] = new SortedSetDocValuesTermsEnum(dv); } else { - // nocommit: need a "pagedbits" - if (dv.getValueCount() > Integer.MAX_VALUE) { - throw new UnsupportedOperationException(); - } - FixedBitSet bitset = new FixedBitSet((int)dv.getValueCount()); + OpenBitSet bitset = new OpenBitSet(dv.getValueCount()); for (int i = 0; i < reader.maxDoc(); i++) { if (liveDocs.get(i)) { dv.setDocument(i); long ord; while ((ord = dv.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) { - bitset.set((int)ord); // nocommit + bitset.set(ord); } } } @@ -610,19 +606,19 @@ public abstract class DocValuesConsumer implements Closeable { ); } - // nocommit: need a "pagedbits" + // TODO: seek-by-ord to nextSetBit static class BitsFilteredTermsEnum extends FilteredTermsEnum { - final Bits liveTerms; + final OpenBitSet liveTerms; - BitsFilteredTermsEnum(TermsEnum in, Bits liveTerms) { + BitsFilteredTermsEnum(TermsEnum in, OpenBitSet liveTerms) { super(in, false); // <-- not passing false here wasted about 3 hours of my time!!!!!!!!!!!!! assert liveTerms != null; this.liveTerms = liveTerms; } - + @Override protected AcceptStatus accept(BytesRef term) throws IOException { - if (liveTerms.get((int) ord())) { + if (liveTerms.get(ord())) { return AcceptStatus.YES; } else { return AcceptStatus.NO; diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java index d5c00d9a788..e3859da6154 100644 --- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java +++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java @@ -42,6 +42,7 @@ import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.CommandLineUtil; import org.apache.lucene.util.FixedBitSet; +import org.apache.lucene.util.OpenBitSet; import org.apache.lucene.util.StringHelper; /** @@ -1335,8 +1336,7 @@ public class CheckIndex { private static void checkSortedSetDocValues(String fieldName, AtomicReader reader, SortedSetDocValues dv) { final long maxOrd = dv.getValueCount()-1; - // nocommit - FixedBitSet seenOrds = new FixedBitSet((int)dv.getValueCount()); + OpenBitSet seenOrds = new OpenBitSet(dv.getValueCount()); long maxOrd2 = -1; for (int i = 0; i < reader.maxDoc(); i++) { dv.setDocument(i); @@ -1351,8 +1351,7 @@ public class CheckIndex { } lastOrd = ord; maxOrd2 = Math.max(maxOrd2, ord); - // nocommit - seenOrds.set((int)ord); + seenOrds.set(ord); } } if (maxOrd != maxOrd2) { diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java index ad6a9cffadd..998bea7835f 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java +++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java @@ -35,6 +35,7 @@ import org.apache.lucene.index.SortedDocValues; import org.apache.lucene.index.SortedSetDocValues; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.FixedBitSet; +import org.apache.lucene.util.OpenBitSet; /** * Just like {@link Lucene42DocValuesFormat} but with additional asserts. @@ -144,8 +145,7 @@ public class AssertingDocValuesFormat extends DocValuesFormat { int docCount = 0; long ordCount = 0; - // nocommit - FixedBitSet seenOrds = new FixedBitSet((int)valueCount); + OpenBitSet seenOrds = new OpenBitSet(valueCount); Iterator ordIterator = ords.iterator(); for (Number v : docToOrdCount) { assert v != null; @@ -161,7 +161,7 @@ public class AssertingDocValuesFormat extends DocValuesFormat { long ord = o.longValue(); assert ord >= 0 && ord < valueCount; assert ord > lastOrd : "ord=" + ord + ",lastOrd=" + lastOrd; - seenOrds.set((int)ord); // nocommit + seenOrds.set(ord); lastOrd = ord; } }