Apache Lucene open-source search software
LUCENE-8475: Remove deprecated constants from RamUsageEstimator.
Adrien Grand2da53c32cbcf
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 133429432cc..c81ae61a97a 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -73,6 +73,9 @@ API Changesmethods from Scorer that should be called from Collectors. LeafCollector.setScorer()now takes a Scorable rather than a Scorer. (Alan Woodward, Adrien Grand)+* LUCENE-8475: Deprecated constants have been removed from RamUsageEstimator.+ (Dimitrios Athanasiou)+Changes in Runtime Behavior* LUCENE-8333: Switch MoreLikeThis.setMaxDocFreqPct to use maxDoc instead ofdiff --git a/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceComparator.java b/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceComparator.javaindex 7a2c5b0e0da..10566b6c8ea 100644--- a/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceComparator.java+++ b/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceComparator.java@@ -28,7 +28,6 @@ import org.apache.lucene.search.FieldComparator;import org.apache.lucene.search.LeafFieldComparator;import org.apache.lucene.search.Scorable;import org.apache.lucene.util.ArrayUtil;-import org.apache.lucene.util.RamUsageEstimator;import org.apache.lucene.util.SloppyMath;import static org.apache.lucene.geo.GeoEncodingUtils.decodeLatitude;@@ -124,7 +123,7 @@ class LatLonPointDistanceComparator extends FieldComparator<Double> implements LvaluesDocID = currentDocs.docID();int count = currentDocs.docValueCount();if (count > currentValues.length) {- currentValues = new long[ArrayUtil.oversize(count, RamUsageEstimator.NUM_BYTES_LONG)];+ currentValues = new long[ArrayUtil.oversize(count, Long.BYTES)];}for(int i=0;i<count;i++) {currentValues[i] = currentDocs.nextValue();diff --git a/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java b/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.javaindex 2765d7f8eb4..0d72e5e233c 100644--- a/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java+++ b/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java@@ -55,56 +55,7 @@ public final class RamUsageEstimator {/** No instantiation. */private RamUsageEstimator() {}- /**- * Number of bytes used to represent a {@code boolean} in binary form- * @deprecated use {@code 1} instead.- */- @Deprecated- public final static int NUM_BYTES_BOOLEAN = 1;- /**- * Number of bytes used to represent a {@code byte} in binary form- * @deprecated use {@code 1} instead.- */- @Deprecated- public final static int NUM_BYTES_BYTE = 1;- /**- * Number of bytes used to represent a {@code char} in binary form- * @deprecated use {@link Character#BYTES} instead.- */- @Deprecated- public final static int NUM_BYTES_CHAR = Character.BYTES;- /**- * Number of bytes used to represent a {@code short} in binary form- * @deprecated use {@link Short#BYTES} instead.- */- @Deprecated- public final static int NUM_BYTES_SHORT = Short.BYTES;- /**- * Number of bytes used to represent an {@code int} in binary form- * @deprecated use {@link Integer#BYTES} instead.- */- @Deprecated- public final static int NUM_BYTES_INT = Integer.BYTES;- /**- * Number of bytes used to represent a {@code float} in binary form- * @deprecated use {@link Float#BYTES} instead.- */- @Deprecated- public final static int NUM_BYTES_FLOAT = Float.BYTES;- /**- * Number of bytes used to represent a {@code long} in binary form- * @deprecated use {@link Long#BYTES} instead.- */- @Deprecated- public final static int NUM_BYTES_LONG = Long.BYTES;- /**- * Number of bytes used to represent a {@code double} in binary form- * @deprecated use {@link Double#BYTES} instead.- */- @Deprecated- public final static int NUM_BYTES_DOUBLE = Double.BYTES;-- /**+ /*** True, iff compressed references (oops) are enabled by this JVM*/public final static boolean COMPRESSED_REFS_ENABLED;diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.java b/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.javaindex 82281a9e0e7..9c2b13df5b4 100644--- a/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.java+++ b/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.java@@ -62,7 +62,7 @@ final class Direct16 extends PackedInts.MutableImpl {public long ramBytesUsed() {return RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_HEADER- + 2 * RamUsageEstimator.NUM_BYTES_INT // valueCount,bitsPerValue+ + 2 * Integer.BYTES // valueCount,bitsPerValue+ RamUsageEstimator.NUM_BYTES_OBJECT_REF) // values ref+ RamUsageEstimator.sizeOf(values);}diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/Direct32.java b/lucene/core/src/java/org/apache/lucene/util/packed/Direct32.javaindex 502aa3f3d6a..169e26267fb 100644--- a/lucene/core/src/java/org/apache/lucene/util/packed/Direct32.java+++ b/lucene/core/src/java/org/apache/lucene/util/packed/Direct32.java@@ -62,7 +62,7 @@ final class Direct32 extends PackedInts.MutableImpl {public long ramBytesUsed() {return RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_HEADER- + 2 * RamUsageEstimator.NUM_BYTES_INT // valueCount,bitsPerValue+ + 2 * Integer.BYTES // valueCount,bitsPerValue+ RamUsageEstimator.NUM_BYTES_OBJECT_REF) // values ref+ RamUsageEstimator.sizeOf(values);}diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/Direct64.java b/lucene/core/src/java/org/apache/lucene/util/packed/Direct64.javaindex 106f641f8cb..7c6badafba1 100644--- a/lucene/core/src/java/org/apache/lucene/util/packed/Direct64.java+++ b/lucene/core/src/java/org/apache/lucene/util/packed/Direct64.java@@ -57,7 +57,7 @@ final class Direct64 extends PackedInts.MutableImpl {public long ramBytesUsed() {return RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_HEADER- + 2 * RamUsageEstimator.NUM_BYTES_INT // valueCount,bitsPerValue+ + 2 * Integer.BYTES // valueCount,bitsPerValue+ RamUsageEstimator.NUM_BYTES_OBJECT_REF) // values ref+ RamUsageEstimator.sizeOf(values);}diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/Direct8.java b/lucene/core/src/java/org/apache/lucene/util/packed/Direct8.javaindex 27986c013f4..fef26c39784 100644--- a/lucene/core/src/java/org/apache/lucene/util/packed/Direct8.java+++ b/lucene/core/src/java/org/apache/lucene/util/packed/Direct8.java@@ -60,7 +60,7 @@ final class Direct8 extends PackedInts.MutableImpl {public long ramBytesUsed() {return RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_HEADER- + 2 * RamUsageEstimator.NUM_BYTES_INT // valueCount,bitsPerValue+ + 2 * Integer.BYTES // valueCount,bitsPerValue+ RamUsageEstimator.NUM_BYTES_OBJECT_REF) // values ref+ RamUsageEstimator.sizeOf(values);}diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/Packed16ThreeBlocks.java b/lucene/core/src/java/org/apache/lucene/util/packed/Packed16ThreeBlocks.javaindex 8e8e94d17ea..fe425eb53ca 100644--- a/lucene/core/src/java/org/apache/lucene/util/packed/Packed16ThreeBlocks.java+++ b/lucene/core/src/java/org/apache/lucene/util/packed/Packed16ThreeBlocks.java@@ -112,7 +112,7 @@ final class Packed16ThreeBlocks extends PackedInts.MutableImpl {public long ramBytesUsed() {return RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_HEADER- + 2 * RamUsageEstimator.NUM_BYTES_INT // valueCount,bitsPerValue+ + 2 * Integer.BYTES // valueCount,bitsPerValue+ RamUsageEstimator.NUM_BYTES_OBJECT_REF) // blocks ref+ RamUsageEstimator.sizeOf(blocks);}diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/Packed64SingleBlock.java b/lucene/core/src/java/org/apache/lucene/util/packed/Packed64SingleBlock.javaindex a7262b3ed90..128d77f0f66 100644--- a/lucene/core/src/java/org/apache/lucene/util/packed/Packed64SingleBlock.java+++ b/lucene/core/src/java/org/apache/lucene/util/packed/Packed64SingleBlock.java@@ -61,7 +61,7 @@ abstract class Packed64SingleBlock extends PackedInts.MutableImpl {public long ramBytesUsed() {return RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_HEADER- + 2 * RamUsageEstimator.NUM_BYTES_INT // valueCount,bitsPerValue+ + 2 * Integer.BYTES // valueCount,bitsPerValue+ RamUsageEstimator.NUM_BYTES_OBJECT_REF) // blocks ref+ RamUsageEstimator.sizeOf(blocks);}diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/Packed8ThreeBlocks.java b/lucene/core/src/java/org/apache/lucene/util/packed/Packed8ThreeBlocks.javaindex 5a85735b3bb..93f6497f152 100644--- a/lucene/core/src/java/org/apache/lucene/util/packed/Packed8ThreeBlocks.java+++ b/lucene/core/src/java/org/apache/lucene/util/packed/Packed8ThreeBlocks.java@@ -110,7 +110,7 @@ final class Packed8ThreeBlocks extends PackedInts.MutableImpl {public long ramBytesUsed() {return RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_HEADER- + 2 * RamUsageEstimator.NUM_BYTES_INT // valueCount,bitsPerValue+ + 2 * Integer.BYTES // valueCount,bitsPerValue+ RamUsageEstimator.NUM_BYTES_OBJECT_REF) // blocks ref+ RamUsageEstimator.sizeOf(blocks);}diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.javaindex 2e4270bcc4c..ea02a0acb55 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java@@ -65,7 +65,7 @@ public class DirectoryTaxonomyReader extends TaxonomyReader implements Accountabprivate static final int DEFAULT_CACHE_VALUE = 4000;// NOTE: very coarse estimate!- private static final int BYTES_PER_CACHE_ENTRY = 4 * RamUsageEstimator.NUM_BYTES_OBJECT_REF + 4 * RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + 8 * RamUsageEstimator.NUM_BYTES_CHAR;+ private static final int BYTES_PER_CACHE_ENTRY = 4 * RamUsageEstimator.NUM_BYTES_OBJECT_REF + 4 * RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + 8 * Character.BYTES;private final DirectoryTaxonomyWriter taxoWriter;private final long taxoEpoch; // used in doOpenIfChangeddiff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/TaxonomyIndexArrays.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/TaxonomyIndexArrays.javaindex dc4d18a6751..c39887b4ec5 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/TaxonomyIndexArrays.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/TaxonomyIndexArrays.java@@ -223,7 +223,7 @@ class TaxonomyIndexArrays extends ParallelTaxonomyArrays implements Accountable@Overridepublic synchronized long ramBytesUsed() {- long ramBytesUsed = RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + 3 * RamUsageEstimator.NUM_BYTES_OBJECT_REF + RamUsageEstimator.NUM_BYTES_BOOLEAN;+ long ramBytesUsed = RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + 3 * RamUsageEstimator.NUM_BYTES_OBJECT_REF + 1;ramBytesUsed += RamUsageEstimator.shallowSizeOf(parents);if (children != null) {ramBytesUsed += RamUsageEstimator.shallowSizeOf(children);