Package org.elasticsearch.common.util
Class BigArrays
java.lang.Object
org.elasticsearch.common.util.BigArrays
public class BigArrays
extends java.lang.Object
Utility class to work with arrays.
-
Field Summary
Fields Modifier and Type Field Description static BigArraysNON_RECYCLING_INSTANCE -
Constructor Summary
Constructors Modifier Constructor Description BigArrays(PageCacheRecycler recycler, CircuitBreakerService breakerService, java.lang.String breakerName)protectedBigArrays(PageCacheRecycler recycler, CircuitBreakerService breakerService, java.lang.String breakerName, boolean checkBreaker) -
Method Summary
Modifier and Type Method Description CircuitBreakerServicebreakerService()booleanequals(ByteArray array, ByteArray other)ByteArraygrow(ByteArray array, long minSize)Grow an array to a size that is larger thanminSize, preserving content, and potentially reusing part of the provided array.DoubleArraygrow(DoubleArray array, long minSize)Grow an array to a size that is larger thanminSize, preserving content, and potentially reusing part of the provided array.FloatArraygrow(FloatArray array, long minSize)Grow an array to a size that is larger thanminSize, preserving content, and potentially reusing part of the provided array.IntArraygrow(IntArray array, long minSize)Grow an array to a size that is larger thanminSize, preserving content, and potentially reusing part of the provided array.LongArraygrow(LongArray array, long minSize)Grow an array to a size that is larger thanminSize, 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 thanminSize, preserving content, and potentially reusing part of the provided array.inthashCode(ByteArray array)ByteArraynewByteArray(long size)Allocate a newByteArrayinitialized with zeros.ByteArraynewByteArray(long size, boolean clearOnResize)Allocate a newByteArray.DoubleArraynewDoubleArray(long size)Allocate a newDoubleArrayof the given capacity.DoubleArraynewDoubleArray(long size, boolean clearOnResize)Allocate a newDoubleArray.FloatArraynewFloatArray(long size)Allocate a newFloatArrayof the given capacity.FloatArraynewFloatArray(long size, boolean clearOnResize)Allocate a newFloatArray.IntArraynewIntArray(long size)Allocate a newIntArray.IntArraynewIntArray(long size, boolean clearOnResize)Allocate a newIntArray.LongArraynewLongArray(long size)Allocate a newLongArray.LongArraynewLongArray(long size, boolean clearOnResize)Allocate a newLongArray.<T> ObjectArray<T>newObjectArray(long size)Allocate a newObjectArray.static longoverSize(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 longoverSize(long minTargetSize, int pageSize, int bytesPerElement)Return the next size to grow to that is >=minTargetSize.ByteArrayresize(ByteArray array, long size)Resize the array to the exact provided size.DoubleArrayresize(DoubleArray array, long size)Resize the array to the exact provided size.FloatArrayresize(FloatArray array, long size)Resize the array to the exact provided size.IntArrayresize(IntArray array, long size)Resize the array to the exact provided size.LongArrayresize(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.BigArrayswithCircuitBreaking()Return an instance of this BigArrays class with circuit breaking explicitly enabled, instead of only accounting enabled
-
Field Details
-
Constructor Details
-
BigArrays
public BigArrays(PageCacheRecycler recycler, @Nullable CircuitBreakerService breakerService, java.lang.String breakerName) -
BigArrays
protected BigArrays(PageCacheRecycler recycler, @Nullable CircuitBreakerService breakerService, java.lang.String breakerName, boolean checkBreaker)
-
-
Method Details
-
overSize
public 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. -
overSize
public static long overSize(long minTargetSize, int pageSize, int bytesPerElement)Return the next size to grow to that is >=minTargetSize. Inspired fromArrayUtil.oversize(int, int)and adapted to play nicely with paging. -
withCircuitBreaking
Return an instance of this BigArrays class with circuit breaking explicitly enabled, instead of only accounting enabled -
breakerService
-
newByteArray
Allocate a newByteArray.- Parameters:
size- the initial length of the arrayclearOnResize- whether values should be set to 0 on initialization and resize
-
newByteArray
Allocate a newByteArrayinitialized with zeros.- Parameters:
size- the initial length of the array
-
resize
Resize the array to the exact provided size. -
grow
Grow an array to a size that is larger thanminSize, preserving content, and potentially reusing part of the provided array. -
hashCode
- See Also:
Arrays.hashCode(byte[])
-
equals
- See Also:
Arrays.equals(byte[], byte[])
-
newIntArray
Allocate a newIntArray.- Parameters:
size- the initial length of the arrayclearOnResize- whether values should be set to 0 on initialization and resize
-
newIntArray
Allocate a newIntArray.- Parameters:
size- the initial length of the array
-
resize
Resize the array to the exact provided size. -
grow
Grow an array to a size that is larger thanminSize, preserving content, and potentially reusing part of the provided array. -
newLongArray
Allocate a newLongArray.- Parameters:
size- the initial length of the arrayclearOnResize- whether values should be set to 0 on initialization and resize
-
newLongArray
Allocate a newLongArray.- Parameters:
size- the initial length of the array
-
resize
Resize the array to the exact provided size. -
grow
Grow an array to a size that is larger thanminSize, preserving content, and potentially reusing part of the provided array. -
newDoubleArray
Allocate a newDoubleArray.- Parameters:
size- the initial length of the arrayclearOnResize- whether values should be set to 0 on initialization and resize
-
newDoubleArray
Allocate a newDoubleArrayof the given capacity. -
resize
Resize the array to the exact provided size. -
grow
Grow an array to a size that is larger thanminSize, preserving content, and potentially reusing part of the provided array. -
newFloatArray
Allocate a newFloatArray.- Parameters:
size- the initial length of the arrayclearOnResize- whether values should be set to 0 on initialization and resize
-
newFloatArray
Allocate a newFloatArrayof the given capacity. -
resize
Resize the array to the exact provided size. -
grow
Grow an array to a size that is larger thanminSize, preserving content, and potentially reusing part of the provided array. -
newObjectArray
Allocate a newObjectArray.- Parameters:
size- the initial length of the array
-
resize
Resize the array to the exact provided size. -
grow
Grow an array to a size that is larger thanminSize, preserving content, and potentially reusing part of the provided array.
-