Package org.apache.hadoop.io
Interface ByteBufferPool
- All Known Implementing Classes:
ElasticByteBufferPool
@Public
@Stable
public interface ByteBufferPool
-
Method Summary
Modifier and TypeMethodDescriptiongetBuffer(boolean direct, int length) Get a new direct ByteBuffer.voidputBuffer(ByteBuffer buffer) Release a buffer back to the pool.default voidrelease()Clear the buffer pool thus releasing all the buffers.
-
Method Details
-
getBuffer
Get a new direct ByteBuffer. The pool can provide this from removing a buffer from its internal cache, or by allocating a new buffer.- Parameters:
direct- Whether the buffer should be direct.length- The minimum length the buffer will have.- Returns:
- A new ByteBuffer. This ByteBuffer must be direct. Its capacity can be less than what was requested, but must be at least 1 byte.
-
putBuffer
Release a buffer back to the pool. The pool may choose to put this buffer into its cache.- Parameters:
buffer- a direct bytebuffer
-
release
default void release()Clear the buffer pool thus releasing all the buffers.
-