Package org.apache.hadoop.hdfs.util
Class ByteArrayManager
java.lang.Object
org.apache.hadoop.hdfs.util.ByteArrayManager
Manage byte array creation and release.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConfiguration for ByteArrayManager. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intleastPowerOfTwo(int n) abstract byte[]newByteArray(int size) Create a byte array for the given length, where the length of the returned array is larger than or equal to the given length.static ByteArrayManagerabstract intrelease(byte[] array) Release the given byte array.
-
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
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 therelease(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 thenewByteArray(int)method.- Returns:
- the number of free array.
-
newInstance
-