Interface DirectAccessInput


public interface DirectAccessInput
An optional interface that an IndexInput can implement to provide direct access to the underlying data as a ByteBuffer. This enables zero-copy access to memory-mapped data for SIMD-accelerated vector scoring.

The byte buffer is passed to the caller's action and is only valid for the duration of that call. All ref-counting and resource releases, if any, is handled internally.

  • Method Details

    • withByteBufferSlice

      boolean withByteBufferSlice(long offset, long length, CheckedConsumer<ByteBuffer,IOException> action) throws IOException
      If a direct byte buffer view is available for the given range, passes it to action and returns true. Otherwise returns false without invoking the action.

      The byte buffer is read-only and valid only for the duration of the action. Callers must not retain references to it after the action returns.

      Parameters:
      offset - the byte offset within the input
      length - the number of bytes requested
      action - the action to perform with the byte buffer
      Returns:
      true if a buffer was available and the action was invoked
      Throws:
      IOException
    • withByteBufferSlices

      boolean withByteBufferSlices(long[] offsets, int length, int count, CheckedConsumer<ByteBuffer[],IOException> action) throws IOException
      Bulk variant of withByteBufferSlice(long, long, org.elasticsearch.core.CheckedConsumer<java.nio.ByteBuffer, java.io.IOException>). Resolves count file ranges to direct byte buffers and invokes the action while all buffers are valid. All ref-counting and resource management is handled internally.

      The byte buffers in the array passed to the action are read-only and valid only for the duration of the action. Callers must not retain references to them after the action returns.

      Parameters:
      offsets - file byte offsets for each range
      length - byte length of each range (same for all)
      count - number of ranges to resolve
      action - receives a ByteBuffer[] where entry i corresponds to offsets[i]
      Returns:
      true if all ranges were available and the action was invoked; false otherwise
      Throws:
      IOException
    • checkSlicesArgs

      static boolean checkSlicesArgs(long[] offsets, int count)
      Validates the offsets and count arguments for withByteBufferSlices(long[], int, int, org.elasticsearch.core.CheckedConsumer<java.nio.ByteBuffer[], java.io.IOException>). Throws on negative count or an undersized offsets array. Returns true if count is zero (caller should treat as a no-op), false otherwise.