Apache Lucene open-source search software
fix some nocommits
Michael McCandless7c962031d5ec
diff --git a/lucene/core/src/java/org/apache/lucene/index/BinaryDocValuesWriter.java b/lucene/core/src/java/org/apache/lucene/index/BinaryDocValuesWriter.javaindex a855b3b438c..c7521894ddc 100644--- a/lucene/core/src/java/org/apache/lucene/index/BinaryDocValuesWriter.java+++ b/lucene/core/src/java/org/apache/lucene/index/BinaryDocValuesWriter.java@@ -36,12 +36,17 @@ class BinaryDocValuesWriter extends DocValuesWriter {private final FieldInfo fieldInfo;private int addedValues = 0;private final BytesRef emptyBytesRef = new BytesRef();+ private final Counter iwBytesUsed;+ private long bytesUsed;// nocommit this needs to update bytesUsed?- public BinaryDocValuesWriter(FieldInfo fieldInfo, Counter counter) {+ public BinaryDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {this.fieldInfo = fieldInfo;- this.bytesRefArray = new BytesRefArray(counter);+ this.bytesRefArray = new BytesRefArray(iwBytesUsed);+ bytesUsed = bytesRefArray.bytesUsed();+ this.iwBytesUsed = iwBytesUsed;+ iwBytesUsed.addAndGet(bytesUsed);}public void addValue(int docID, BytesRef value) {@@ -62,6 +67,13 @@ class BinaryDocValuesWriter extends DocValuesWriter {}addedValues++;bytesRefArray.append(value);+ updateBytesUsed();+ }++ private void updateBytesUsed() {+ final long newBytesUsed = bytesRefArray.bytesUsed();+ iwBytesUsed.addAndGet(newBytesUsed - bytesUsed);+ bytesUsed = newBytesUsed;}@Override@@ -104,19 +116,9 @@ class BinaryDocValuesWriter extends DocValuesWriter {};}});-- // nocommit- //reset();}@Overridepublic void abort() {- // nocommit- //reset();- }-- private void reset() {- // nocommit- //bytesRefArray.clear();}}\ No newline at end of filediff --git a/lucene/core/src/java/org/apache/lucene/index/NumericDocValuesWriter.java b/lucene/core/src/java/org/apache/lucene/index/NumericDocValuesWriter.javaindex 20742e084e5..368e67f7f79 100644--- a/lucene/core/src/java/org/apache/lucene/index/NumericDocValuesWriter.java+++ b/lucene/core/src/java/org/apache/lucene/index/NumericDocValuesWriter.java@@ -42,6 +42,7 @@ class NumericDocValuesWriter extends DocValuesWriter {bytesUsed = pending.ramBytesUsed();this.fieldInfo = fieldInfo;this.iwBytesUsed = iwBytesUsed;+ iwBytesUsed.addAndGet(bytesUsed);}public void addValue(int docID, long value) {@@ -108,22 +109,9 @@ class NumericDocValuesWriter extends DocValuesWriter {};}});-- // nocommit- //reset();}@Overridepublic void abort() {- // nocommit- //reset();- }-- // nocommit do we really need this...? can't/doesn't parent alloc- // a new instance after flush?- void reset() {- // nocommit- //pending = new AppendingLongBuffer();- //updateBytesUsed();}}\ No newline at end of filediff --git a/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesWriter.java b/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesWriter.javaindex dbe1d9faabd..dd45a21945b 100644--- a/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesWriter.java+++ b/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesWriter.java@@ -39,6 +39,7 @@ class SortedDocValuesWriter extends DocValuesWriter {private int[] pending = new int[DEFAULT_PENDING_SIZE];private int pendingIndex = 0;private final Counter iwBytesUsed;+ private long bytesUsed;private final FieldInfo fieldInfo;private static final BytesRef EMPTY = new BytesRef(BytesRef.EMPTY_BYTES);@@ -85,7 +86,7 @@ class SortedDocValuesWriter extends DocValuesWriter {int ord = hash.add(value);if (ord < 0) {ord = -ord-1;- }+ }if (pendingIndex <= pending.length) {int pendingLen = pending.length;@@ -116,7 +117,6 @@ class SortedDocValuesWriter extends DocValuesWriter {final int[] sortedValues = hash.sort(BytesRef.getUTF8SortedAsUnicodeComparator());final int sortedValueRamUsage = RamUsageEstimator.NUM_BYTES_ARRAY_HEADER + RamUsageEstimator.NUM_BYTES_INT*valueCount;- iwBytesUsed.addAndGet(sortedValueRamUsage);final int[] ordMap = new int[valueCount];for(int ord=0;ord<valueCount;ord++) {@@ -187,25 +187,9 @@ class SortedDocValuesWriter extends DocValuesWriter {};}});-- iwBytesUsed.addAndGet(-sortedValueRamUsage);- // nocommit- //reset();}@Overridepublic void abort() {- // nocommit- //reset();- }-- private void reset() {- // nocommit- /*- iwBytesUsed.addAndGet((pending.length - DEFAULT_PENDING_SIZE) * RamUsageEstimator.NUM_BYTES_INT);- pending = ArrayUtil.shrink(pending, DEFAULT_PENDING_SIZE);- pendingIndex = 0;- hash.clear();- */}}diff --git a/lucene/core/src/java/org/apache/lucene/util/BytesRefHash.java b/lucene/core/src/java/org/apache/lucene/util/BytesRefHash.javaindex d8b110bff3a..9a10c5beb1a 100644--- a/lucene/core/src/java/org/apache/lucene/util/BytesRefHash.java+++ b/lucene/core/src/java/org/apache/lucene/util/BytesRefHash.java@@ -208,8 +208,7 @@ public final class BytesRefHash {newSize /= 2;}if (newSize != hashSize) {- bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_INT- * -(hashSize - newSize));+ bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_INT * -(hashSize - newSize));hashSize = newSize;ords = new int[hashSize];Arrays.fill(ords, -1);@@ -248,8 +247,7 @@ public final class BytesRefHash {public void close() {clear(true);ords = null;- bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_INT- * -hashSize);+ bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_INT * -hashSize);}/**diff --git a/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.javaindex 0d3186cf0c2..49652a94ffe 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java@@ -64,6 +64,8 @@ import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.Ignore;+// nocommit fails: ant test -Dtestcase=TestBackwardsCompatibility -Dtests.method=testExactFileNames -Dtests.seed=F5A14C72AFCA024E -Dtests.slow=true -Dtests.locale=pl_PL -Dtests.timezone=America/Argentina/La_Rioja -Dtests.file.encoding=ISO-8859-1+/*Verify we can read the pre-5.0 file format, do searchesagainst it, and add documents to it.