Skip to content

Apache Lucene open-source search software

LUCENE-6242: Fix SparseFixedBitSet ram usage estimation when object alignment is different from 8.

Adrien Grandccb111b48ea3
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 23896727e74..5130343602f 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -50,6 +50,9 @@ Bug Fixes
* LUCENE-6190: Spatial pointsOnly flag on PrefixTreeStrategy shouldn't switch all predicates to
Intersects. (David Smiley)
+* LUCENE-6242: Ram usage estimation was incorrect for SparseFixedBitSet when
+ object alignment was different from 8. (Uwe Schindler, Adrien Grand)
+
Optimizations
* LUCENE-6183, LUCENE-5647: Avoid recompressing stored fields
diff --git a/lucene/core/src/java/org/apache/lucene/util/SparseFixedBitSet.java b/lucene/core/src/java/org/apache/lucene/util/SparseFixedBitSet.java
index 0ee27e55b1d..2f93a0acb6d 100644
--- a/lucene/core/src/java/org/apache/lucene/util/SparseFixedBitSet.java
+++ b/lucene/core/src/java/org/apache/lucene/util/SparseFixedBitSet.java
@@ -184,7 +184,7 @@ public class SparseFixedBitSet extends BitSet implements Bits, Accountable {
newBitArray[o] = 1L << i;
System.arraycopy(bitArray, o, newBitArray, o + 1, bitArray.length - o);
bits[i4096] = newBitArray;
- ramBytesUsed += (newSize - bitArray.length) * RamUsageEstimator.NUM_BYTES_LONG;
+ ramBytesUsed += RamUsageEstimator.sizeOf(newBitArray) - RamUsageEstimator.sizeOf(bitArray);
}
++nonZeroLongCount;
}