/** * Ensure {@code buf} is large enough for {@code outputLength}. If not, it is cleaned up and a new buffer is allocated; * else; buffer has it's position/limit set appropriately. * * @param buf buffer to test the size of; may be null, in which case, a new buffer is allocated. * @param outputLength the minimum target size of the buffer * @param allowBufferResize true if resizing (reallocating) the buffer is allowed * @return {@code buf} if it was large enough, else a newly allocated buffer. */ public static ByteBuffer ensureCapacity(ByteBuffer buf, int outputLength, boolean allowBufferResize) { BufferType bufferType = buf != null ? BufferType.typeOf(buf) : BufferType.ON_HEAP; return ensureCapacity(buf, outputLength, allowBufferResize, bufferType); }
/** * Ensure {@code buf} is large enough for {@code outputLength}. If not, it is cleaned up and a new buffer is allocated; * else; buffer has it's position/limit set appropriately. * * @param buf buffer to test the size of; may be null, in which case, a new buffer is allocated. * @param outputLength the minimum target size of the buffer * @param allowBufferResize true if resizing (reallocating) the buffer is allowed * @return {@code buf} if it was large enough, else a newly allocated buffer. */ public static ByteBuffer ensureCapacity(ByteBuffer buf, int outputLength, boolean allowBufferResize) { BufferType bufferType = buf != null ? BufferType.typeOf(buf) : BufferType.ON_HEAP; return ensureCapacity(buf, outputLength, allowBufferResize, bufferType); }
/** * Ensure {@code buf} is large enough for {@code outputLength}. If not, it is cleaned up and a new buffer is allocated; * else; buffer has it's position/limit set appropriately. * * @param buf buffer to test the size of; may be null, in which case, a new buffer is allocated. * @param outputLength the minimum target size of the buffer * @param allowBufferResize true if resizing (reallocating) the buffer is allowed * @return {@code buf} if it was large enough, else a newly allocated buffer. */ public static ByteBuffer ensureCapacity(ByteBuffer buf, int outputLength, boolean allowBufferResize) { BufferType bufferType = buf != null ? BufferType.typeOf(buf) : BufferType.ON_HEAP; return ensureCapacity(buf, outputLength, allowBufferResize, bufferType); }
/** * Ensure {@code buf} is large enough for {@code outputLength}. If not, it is cleaned up and a new buffer is allocated; * else; buffer has it's position/limit set appropriately. * * @param buf buffer to test the size of; may be null, in which case, a new buffer is allocated. * @param outputLength the minimum target size of the buffer * @param allowBufferResize true if resizing (reallocating) the buffer is allowed * @return {@code buf} if it was large enough, else a newly allocated buffer. */ public static ByteBuffer ensureCapacity(ByteBuffer buf, int outputLength, boolean allowBufferResize) { BufferType bufferType = buf != null ? BufferType.typeOf(buf) : BufferType.ON_HEAP; return ensureCapacity(buf, outputLength, allowBufferResize, bufferType); }
/** * Ensure {@code buf} is large enough for {@code outputLength}. If not, it is cleaned up and a new buffer is allocated; * else; buffer has it's position/limit set appropriately. * * @param buf buffer to test the size of; may be null, in which case, a new buffer is allocated. * @param outputLength the minimum target size of the buffer * @param allowBufferResize true if resizing (reallocating) the buffer is allowed * @return {@code buf} if it was large enough, else a newly allocated buffer. */ public static ByteBuffer ensureCapacity(ByteBuffer buf, int outputLength, boolean allowBufferResize) { BufferType bufferType = buf != null ? BufferType.typeOf(buf) : BufferType.ON_HEAP; return ensureCapacity(buf, outputLength, allowBufferResize, bufferType); }
public ByteBuffer getThreadLocalReusableBuffer(int size) { ByteBuffer result = reusableBufferHolder.get(); if (result.capacity() < size || BufferType.typeOf(result) != preferredReusableBufferType) { FileUtils.clean(result); result = preferredReusableBufferType.allocate(size); reusableBufferHolder.set(result); } return result; }
public ByteBuffer getThreadLocalReusableBuffer(int size) { ByteBuffer result = reusableBufferHolder.get(); if (result.capacity() < size || BufferType.typeOf(result) != preferredReusableBufferType) { FileUtils.clean(result); result = preferredReusableBufferType.allocate(size); reusableBufferHolder.set(result); } return result; }
public ByteBuffer getThreadLocalReusableBuffer(int size) { ByteBuffer result = reusableBufferHolder.get(); if (result.capacity() < size || BufferType.typeOf(result) != preferredReusableBufferType) { FileUtils.clean(result); result = preferredReusableBufferType.allocate(size); reusableBufferHolder.set(result); } return result; }