Interface DirectBufferFactory
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
DirectReadBuffers for StorageObject.readBytesAsync(long, long, org.elasticsearch.xpack.esql.datasources.spi.DirectBufferFactory, java.util.concurrent.Executor, org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.esql.datasources.spi.DirectReadBuffer>).
A factory bundles together "where the bytes go" (a destination off-heap buffer) and "what
gets charged for them" (the underlying allocator / circuit breaker). Backends only see this
one-method abstraction, so they need not depend on any specific direct-memory implementation
(Arrow today, anything else later). The bridge from a concrete allocator to this interface is
confined to forAllocator(BufferAllocator) and to call sites that build a factory
differently (e.g. tests that fake the allocation).
allocate(int) may throw IOException when the underlying allocator refuses
the allocation (circuit-breaker trip, OOM, etc.). On success the returned buffer is uninitialized
and the caller is responsible for closing it once consumption is complete or on the failure path.
-
Method Summary
Modifier and TypeMethodDescriptionallocate(int length) static DirectBufferFactoryforAllocator(org.apache.arrow.memory.BufferAllocator allocator) Returns a factory that allocates from the given ArrowBufferAllocator.
-
Method Details
-
allocate
- Throws:
IOException
-
forAllocator
Returns a factory that allocates from the given ArrowBufferAllocator. This is the one supported bridge from a concrete allocator toDirectBufferFactory; production code calls it once at the boundary that owns the allocator (currentlyCoalescedRangeReader).
-