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.

@FunctionalInterface public interface DirectBufferFactory
Producer of 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 Type
    Method
    Description
    allocate(int length)
     
    forAllocator(org.apache.arrow.memory.BufferAllocator allocator)
    Returns a factory that allocates from the given Arrow BufferAllocator.
  • Method Details

    • allocate

      DirectReadBuffer allocate(int length) throws IOException
      Throws:
      IOException
    • forAllocator

      static DirectBufferFactory forAllocator(org.apache.arrow.memory.BufferAllocator allocator)
      Returns a factory that allocates from the given Arrow BufferAllocator. This is the one supported bridge from a concrete allocator to DirectBufferFactory; production code calls it once at the boundary that owns the allocator (currently CoalescedRangeReader).