ByteBlockPool
This class enables the allocation of fixed-size buffers and their management as part of a buffer array. Allocation is done through the use of an Allocator which can be customized, e.g. to allow recycling old buffers. There are methods for writing (.append and reading from the buffers (e.g. .readBytes, which handle read/write operations across buffer boundaries.
Types
Properties
Offset from the start of the first buffer to the start of the current buffer, which is bufferUpto * BYTE_BLOCK_SIZE. The buffer pool maintains this offset because it is the first to overflow if there are too many allocated blocks.
Returns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).
Functions
Appends the bytes in the provided BytesRef at the current position.
Append the provided byte array at the current position.
Append the bytes from a source ByteBlockPool at a given offset and length
Return the memory usage of this object in bytes. Negative values are illegal.
Expert: Resets the pool to its initial state, while optionally reusing the first buffer. Buffers that are not reused are reclaimed by Allocator.recycleByteBlocks. Buffers can be filled with zeros before recycling them. This is useful if a slice pool works on top of this byte pool and relies on the buffers being filled with zeros to find the non-zero end of slices.
Fill the provided BytesRef with the bytes at the specified offset and length. This will avoid copying the bytes if the slice fits into a single block; otherwise, it uses the provided BytesRefBuilder to copy bytes over.