Class BigArrays

java.lang.Object
org.opensearch.common.util.BigArrays

@PublicApi(since="1.0.0") public class BigArrays extends Object
Utility class to work with arrays.
Opensearch.api:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A double value binary searcher
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BigArrays
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    BigArrays(PageCacheRecycler recycler, org.opensearch.core.indices.breaker.CircuitBreakerService breakerService, String breakerName)
     
    protected
    BigArrays(PageCacheRecycler recycler, org.opensearch.core.indices.breaker.CircuitBreakerService breakerService, String breakerName, boolean checkBreaker)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.opensearch.core.indices.breaker.CircuitBreakerService
     
    boolean
    equals(org.opensearch.core.common.util.ByteArray array, org.opensearch.core.common.util.ByteArray other)
     
    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.
    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.
    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.
    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.
    org.opensearch.core.common.util.ByteArray
    grow(org.opensearch.core.common.util.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.
    int
    hashCode(org.opensearch.core.common.util.ByteArray array)
     
    org.opensearch.core.common.util.ByteArray
    newByteArray(long size)
    Allocate a new ByteArray initialized with zeros.
    org.opensearch.core.common.util.ByteArray
    newByteArray(long size, boolean clearOnResize)
    Allocate a new ByteArray.
    newDoubleArray(long size)
    Allocate a new DoubleArray of the given capacity.
    newDoubleArray(long size, boolean clearOnResize)
    Allocate a new DoubleArray.
    newFloatArray(long size)
    Allocate a new FloatArray of the given capacity.
    newFloatArray(long size, boolean clearOnResize)
    Allocate a new FloatArray.
    newIntArray(long size)
    Allocate a new IntArray.
    newIntArray(long size, boolean clearOnResize)
    Allocate a new IntArray.
    newLongArray(long size)
    Allocate a new 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.
    resize(DoubleArray array, long size)
    Resize the array to the exact provided size.
    resize(FloatArray array, long size)
    Resize the array to the exact provided size.
    resize(IntArray array, long size)
    Resize the array to the exact provided size.
    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.
    org.opensearch.core.common.util.ByteArray
    resize(org.opensearch.core.common.util.ByteArray array, long size)
    Resize the array to the exact provided size.
    Return an instance of this BigArrays class with circuit breaking explicitly enabled, instead of only accounting enabled

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NON_RECYCLING_INSTANCE

      public static final BigArrays NON_RECYCLING_INSTANCE
  • Constructor Details

    • BigArrays

      public BigArrays(PageCacheRecycler recycler, @Nullable org.opensearch.core.indices.breaker.CircuitBreakerService breakerService, String breakerName)
    • BigArrays

      protected BigArrays(PageCacheRecycler recycler, @Nullable org.opensearch.core.indices.breaker.CircuitBreakerService breakerService, 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 from ArrayUtil.oversize(int, int) and adapted to play nicely with paging.
    • withCircuitBreaking

      public BigArrays withCircuitBreaking()
      Return an instance of this BigArrays class with circuit breaking explicitly enabled, instead of only accounting enabled
    • breakerService

      public org.opensearch.core.indices.breaker.CircuitBreakerService breakerService()
    • newByteArray

      public org.opensearch.core.common.util.ByteArray newByteArray(long size, boolean clearOnResize)
      Allocate a new ByteArray.
      Parameters:
      size - the initial length of the array
      clearOnResize - whether values should be set to 0 on initialization and resize
    • newByteArray

      public org.opensearch.core.common.util.ByteArray newByteArray(long size)
      Allocate a new ByteArray initialized with zeros.
      Parameters:
      size - the initial length of the array
    • resize

      public org.opensearch.core.common.util.ByteArray resize(org.opensearch.core.common.util.ByteArray array, long size)
      Resize the array to the exact provided size.
    • grow

      public org.opensearch.core.common.util.ByteArray grow(org.opensearch.core.common.util.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.
    • hashCode

      public int hashCode(org.opensearch.core.common.util.ByteArray array)
      See Also:
    • equals

      public boolean equals(org.opensearch.core.common.util.ByteArray array, org.opensearch.core.common.util.ByteArray other)
      See Also:
    • newIntArray

      public IntArray newIntArray(long size, boolean clearOnResize)
      Allocate a new IntArray.
      Parameters:
      size - the initial length of the array
      clearOnResize - whether values should be set to 0 on initialization and resize
    • newIntArray

      public IntArray newIntArray(long size)
      Allocate a new IntArray.
      Parameters:
      size - the initial length of the array
    • resize

      public IntArray resize(IntArray array, long size)
      Resize the array to the exact provided size.
    • grow

      public 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.
    • newLongArray

      public LongArray newLongArray(long size, boolean clearOnResize)
      Allocate a new LongArray.
      Parameters:
      size - the initial length of the array
      clearOnResize - whether values should be set to 0 on initialization and resize
    • newLongArray

      public LongArray newLongArray(long size)
      Allocate a new LongArray.
      Parameters:
      size - the initial length of the array
    • resize

      public LongArray resize(LongArray array, long size)
      Resize the array to the exact provided size.
    • grow

      public 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.
    • newDoubleArray

      public DoubleArray newDoubleArray(long size, boolean clearOnResize)
      Allocate a new DoubleArray.
      Parameters:
      size - the initial length of the array
      clearOnResize - whether values should be set to 0 on initialization and resize
    • newDoubleArray

      public DoubleArray newDoubleArray(long size)
      Allocate a new DoubleArray of the given capacity.
    • resize

      public DoubleArray resize(DoubleArray array, long size)
      Resize the array to the exact provided size.
    • grow

      public 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.
    • newFloatArray

      public FloatArray newFloatArray(long size, boolean clearOnResize)
      Allocate a new FloatArray.
      Parameters:
      size - the initial length of the array
      clearOnResize - whether values should be set to 0 on initialization and resize
    • newFloatArray

      public FloatArray newFloatArray(long size)
      Allocate a new FloatArray of the given capacity.
    • resize

      public FloatArray resize(FloatArray array, long size)
      Resize the array to the exact provided size.
    • grow

      public 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.
    • newObjectArray

      public <T> ObjectArray<T> newObjectArray(long size)
      Allocate a new ObjectArray.
      Parameters:
      size - the initial length of the array
    • resize

      public <T> ObjectArray<T> resize(ObjectArray<T> array, long size)
      Resize the array to the exact provided size.
    • grow

      public <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.