Skip to content

Commit aa872e8

Browse files
committed
Hide RamUsageEstimator from the public API. #244
1 parent 422c79a commit aa872e8

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

CHANGES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
** New features and API changes
55

6+
GH-244: Hide RamUsageEstimator from the public API. (Dawid Weiss)
7+
68
GH-239: Minimum Java bumped to 11 (from 8). (Dawid Weiss)
79

810
GH-235: Drop WormMap and WormSet.

hppc/src/main/java/com/carrotsearch/hppc/RamUsageEstimator.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,39 @@
2020
*
2121
* <p>Mostly forked from Lucene tag releases/lucene-solr/8.5.1
2222
*/
23-
public class RamUsageEstimator {
23+
final class RamUsageEstimator {
2424
/** One kilobyte bytes. */
25-
public static final long ONE_KB = 1024;
25+
static final long ONE_KB = 1024;
2626

2727
/** One megabyte bytes. */
28-
public static final long ONE_MB = ONE_KB * ONE_KB;
28+
static final long ONE_MB = ONE_KB * ONE_KB;
2929

3030
/** One gigabyte bytes. */
31-
public static final long ONE_GB = ONE_KB * ONE_MB;
31+
static final long ONE_GB = ONE_KB * ONE_MB;
3232

3333
/** No instantiation. */
3434
private RamUsageEstimator() {}
3535

3636
/** True, iff compressed references (oops) are enabled by this JVM */
37-
public static final boolean COMPRESSED_REFS_ENABLED;
37+
static final boolean COMPRESSED_REFS_ENABLED;
3838

3939
/** Number of bytes this JVM uses to represent an object reference. */
40-
public static final int NUM_BYTES_OBJECT_REF;
40+
static final int NUM_BYTES_OBJECT_REF;
4141

4242
/** Number of bytes to represent an object header (no fields, no alignments). */
43-
public static final int NUM_BYTES_OBJECT_HEADER;
43+
static final int NUM_BYTES_OBJECT_HEADER;
4444

4545
/** Number of bytes to represent an array header (no content, but with alignments). */
46-
public static final int NUM_BYTES_ARRAY_HEADER;
46+
static final int NUM_BYTES_ARRAY_HEADER;
4747

4848
/**
4949
* A constant specifying the object alignment boundary inside the JVM. Objects will always take a
5050
* full multiple of this constant, possibly wasting some space.
5151
*/
52-
public static final int NUM_BYTES_OBJECT_ALIGNMENT;
52+
static final int NUM_BYTES_OBJECT_ALIGNMENT;
5353

5454
/** Sizes of primitive classes. */
55-
public static final Map<Class<?>, Integer> primitiveSizes;
55+
static final Map<Class<?>, Integer> primitiveSizes;
5656

5757
static {
5858
Map<Class<?>, Integer> primitiveSizesMap = new IdentityHashMap<>();
@@ -141,7 +141,7 @@ private RamUsageEstimator() {}
141141
}
142142

143143
/** Aligns an object size to be the next multiple of {@link #NUM_BYTES_OBJECT_ALIGNMENT}. */
144-
public static long alignObjectSize(long size) {
144+
static long alignObjectSize(long size) {
145145
size += (long) NUM_BYTES_OBJECT_ALIGNMENT - 1L;
146146
return size - (size % NUM_BYTES_OBJECT_ALIGNMENT);
147147
}
@@ -151,7 +151,7 @@ public static long alignObjectSize(long size) {
151151
*
152152
* @param usedSize Size that array is actually used
153153
*/
154-
public static long shallowUsedSizeOfArray(Object array, int usedSize) {
154+
static long shallowUsedSizeOfArray(Object array, int usedSize) {
155155
long size = NUM_BYTES_ARRAY_HEADER;
156156
if (usedSize > 0) {
157157
Class<?> arrayElementClazz = array.getClass().getComponentType();
@@ -165,7 +165,7 @@ public static long shallowUsedSizeOfArray(Object array, int usedSize) {
165165
}
166166

167167
/** Return shallow size of any <code>array</code>. */
168-
public static long shallowSizeOfArray(Object array) {
168+
static long shallowSizeOfArray(Object array) {
169169
return shallowUsedSizeOfArray(array, Array.getLength(array));
170170
}
171171
}

0 commit comments

Comments
 (0)