Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ private RamUsageEstimator() {}
*/
public static final int NUM_BYTES_OBJECT_ALIGNMENT;

private static final int ALIGN_MASK;

/**
* Approximate memory usage that we assign to all unknown queries - this maps roughly to a
* BooleanQuery with a couple term clauses.
Expand Down Expand Up @@ -180,6 +182,8 @@ private RamUsageEstimator() {}
NUM_BYTES_ARRAY_HEADER = NUM_BYTES_OBJECT_HEADER + Integer.BYTES;
}

ALIGN_MASK = NUM_BYTES_OBJECT_ALIGNMENT - 1;

// get min/max value of cached Long class instances:
long longCacheMinValue = 0;
while (longCacheMinValue > Long.MIN_VALUE
Expand Down Expand Up @@ -209,8 +213,7 @@ private RamUsageEstimator() {}

/** Aligns an object size to be the next multiple of {@link #NUM_BYTES_OBJECT_ALIGNMENT}. */
public static long alignObjectSize(long size) {
size += NUM_BYTES_OBJECT_ALIGNMENT - 1L;
return size - (size % NUM_BYTES_OBJECT_ALIGNMENT);
return (size + ALIGN_MASK) & ~ALIGN_MASK;
}

/**
Expand Down
Loading