Class ByteArrayManager

java.lang.Object
org.apache.hadoop.hdfs.util.ByteArrayManager

@Private public abstract class ByteArrayManager extends Object
Manage byte array creation and release.
  • Constructor Details

    • ByteArrayManager

      public ByteArrayManager()
  • Method Details

    • leastPowerOfTwo

      public static int leastPowerOfTwo(int n)
      Returns:
      the least power of two greater than or equal to n, i.e. return the least integer x with x >= n and x a power of two.
      Throws:
      org.apache.hadoop.HadoopIllegalArgumentException - if n <= 0.
    • newByteArray

      public abstract byte[] newByteArray(int size) throws InterruptedException
      Create a byte array for the given length, where the length of the returned array is larger than or equal to the given length. The current thread may be blocked if some resource is unavailable. The byte array created by this method must be released via the release(byte[]) method.
      Returns:
      a byte array with length larger than or equal to the given length.
      Throws:
      InterruptedException
    • release

      public abstract int release(byte[] array)
      Release the given byte array. The byte array may or may not be created by the newByteArray(int) method.
      Returns:
      the number of free array.
    • newInstance

      public static ByteArrayManager newInstance(ByteArrayManager.Conf conf)