public class BigArrays extends java.lang.Object implements Releasable
Modifier and Type | Field and Description |
---|---|
static int |
BYTE_PAGE_SIZE |
static int |
INT_PAGE_SIZE |
static int |
LONG_PAGE_SIZE |
static BigArrays |
NON_RECYCLING_INSTANCE |
static int |
OBJECT_PAGE_SIZE |
static int |
PAGE_SIZE_IN_BYTES
Page size in bytes: 16KB
|
Constructor and Description |
---|
BigArrays(PageCacheRecycler recycler,
CircuitBreakerService breakerService,
boolean checkBreaker) |
BigArrays(Settings settings,
CircuitBreakerService breakerService) |
Modifier and Type | Method and Description |
---|---|
CircuitBreakerService |
breakerService() |
void |
close() |
boolean |
equals(ByteArray array,
ByteArray other) |
ByteArray |
grow(ByteArray array,
long minSize)
Grow an array to a size that is larger than
minSize , preserving content, and potentially reusing part of the provided array. |
DoubleArray |
grow(DoubleArray array,
long minSize)
Grow an array to a size that is larger than
minSize , preserving content, and potentially reusing part of the provided array. |
FloatArray |
grow(FloatArray array,
long minSize)
Grow an array to a size that is larger than
minSize , preserving content, and potentially reusing part of the provided array. |
IntArray |
grow(IntArray array,
long minSize)
Grow an array to a size that is larger than
minSize , preserving content, and potentially reusing part of the provided array. |
LongArray |
grow(LongArray array,
long minSize)
Grow an array to a size that is larger than
minSize , preserving content, and potentially reusing part of the provided array. |
<T> ObjectArray<T> |
grow(ObjectArray<T> array,
long minSize)
Grow an array to a size that is larger than
minSize , preserving content, and potentially reusing part of the provided array. |
int |
hashCode(ByteArray array) |
ByteArray |
newByteArray(long size)
Allocate a new
ByteArray initialized with zeros. |
ByteArray |
newByteArray(long size,
boolean clearOnResize)
Allocate a new
ByteArray . |
DoubleArray |
newDoubleArray(long size)
Allocate a new
DoubleArray of the given capacity. |
DoubleArray |
newDoubleArray(long size,
boolean clearOnResize)
Allocate a new
DoubleArray . |
FloatArray |
newFloatArray(long size)
Allocate a new
FloatArray of the given capacity. |
FloatArray |
newFloatArray(long size,
boolean clearOnResize)
Allocate a new
FloatArray . |
IntArray |
newIntArray(long size)
Allocate a new
IntArray . |
IntArray |
newIntArray(long size,
boolean clearOnResize)
Allocate a new
IntArray . |
LongArray |
newLongArray(long size)
Allocate a new
LongArray . |
LongArray |
newLongArray(long size,
boolean clearOnResize)
Allocate a new
LongArray . |
<T> ObjectArray<T> |
newObjectArray(long size)
Allocate a new
ObjectArray . |
static long |
overSize(long minTargetSize)
Returns the next size to grow when working with parallel arrays that may have different page sizes or number of bytes per element.
|
static long |
overSize(long minTargetSize,
int pageSize,
int bytesPerElement)
Return the next size to grow to that is >=
minTargetSize . |
ByteArray |
resize(ByteArray array,
long size)
Resize the array to the exact provided size.
|
DoubleArray |
resize(DoubleArray array,
long size)
Resize the array to the exact provided size.
|
FloatArray |
resize(FloatArray array,
long size)
Resize the array to the exact provided size.
|
IntArray |
resize(IntArray array,
long size)
Resize the array to the exact provided size.
|
LongArray |
resize(LongArray array,
long size)
Resize the array to the exact provided size.
|
<T> ObjectArray<T> |
resize(ObjectArray<T> array,
long size)
Resize the array to the exact provided size.
|
BigArrays |
withCircuitBreaking()
Return an instance of this BigArrays class with circuit breaking
explicitly enabled, instead of only accounting enabled
|
public static final BigArrays NON_RECYCLING_INSTANCE
public static final int PAGE_SIZE_IN_BYTES
public static final int BYTE_PAGE_SIZE
public static final int INT_PAGE_SIZE
public static final int LONG_PAGE_SIZE
public static final int OBJECT_PAGE_SIZE
public BigArrays(Settings settings, @Nullable CircuitBreakerService breakerService)
public BigArrays(PageCacheRecycler recycler, @Nullable CircuitBreakerService breakerService, boolean checkBreaker)
public static long overSize(long minTargetSize)
public static long overSize(long minTargetSize, int pageSize, int bytesPerElement)
minTargetSize
.
Inspired from ArrayUtil.oversize(int, int)
and adapted to play nicely with paging.public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface Releasable
public BigArrays withCircuitBreaking()
public CircuitBreakerService breakerService()
public ByteArray newByteArray(long size, boolean clearOnResize)
ByteArray
.size
- the initial length of the arrayclearOnResize
- whether values should be set to 0 on initialization and resizepublic ByteArray newByteArray(long size)
ByteArray
initialized with zeros.size
- the initial length of the arraypublic ByteArray resize(ByteArray array, long size)
public ByteArray grow(ByteArray array, long minSize)
minSize
, preserving content, and potentially reusing part of the provided array.public int hashCode(ByteArray array)
Arrays.hashCode(byte[])
public boolean equals(ByteArray array, ByteArray other)
Arrays.equals(byte[], byte[])
public IntArray newIntArray(long size, boolean clearOnResize)
IntArray
.size
- the initial length of the arrayclearOnResize
- whether values should be set to 0 on initialization and resizepublic IntArray newIntArray(long size)
IntArray
.size
- the initial length of the arraypublic IntArray resize(IntArray array, long size)
public IntArray grow(IntArray array, long minSize)
minSize
, preserving content, and potentially reusing part of the provided array.public LongArray newLongArray(long size, boolean clearOnResize)
LongArray
.size
- the initial length of the arrayclearOnResize
- whether values should be set to 0 on initialization and resizepublic LongArray newLongArray(long size)
LongArray
.size
- the initial length of the arraypublic LongArray resize(LongArray array, long size)
public LongArray grow(LongArray array, long minSize)
minSize
, preserving content, and potentially reusing part of the provided array.public DoubleArray newDoubleArray(long size, boolean clearOnResize)
DoubleArray
.size
- the initial length of the arrayclearOnResize
- whether values should be set to 0 on initialization and resizepublic DoubleArray newDoubleArray(long size)
DoubleArray
of the given capacity.public DoubleArray resize(DoubleArray array, long size)
public DoubleArray grow(DoubleArray array, long minSize)
minSize
, preserving content, and potentially reusing part of the provided array.public FloatArray newFloatArray(long size, boolean clearOnResize)
FloatArray
.size
- the initial length of the arrayclearOnResize
- whether values should be set to 0 on initialization and resizepublic FloatArray newFloatArray(long size)
FloatArray
of the given capacity.public FloatArray resize(FloatArray array, long size)
public FloatArray grow(FloatArray array, long minSize)
minSize
, preserving content, and potentially reusing part of the provided array.public <T> ObjectArray<T> newObjectArray(long size)
ObjectArray
.size
- the initial length of the arraypublic <T> ObjectArray<T> resize(ObjectArray<T> array, long size)
public <T> ObjectArray<T> grow(ObjectArray<T> array, long minSize)
minSize
, preserving content, and potentially reusing part of the provided array.