public interface DirectAccessInput
An optional interface that an IndexInput can implement to provide direct
access to the underlying data as a
MemorySegment. This enables
zero-copy access to memory-mapped data for SIMD-accelerated vector scoring.
The memory segment 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 Summary
Modifier and TypeMethodDescriptionstatic booleancheckSlicesArgs(long[] offsets, int count) Validates theoffsetsandcountarguments forwithMemorySegmentSlices(long[], int, int, org.elasticsearch.core.CheckedConsumer<java.lang.foreign.MemorySegment[], java.io.IOException>).booleanwithMemorySegmentSlice(long offset, long length, CheckedConsumer<MemorySegment, IOException> action) If a direct memory segment view is available for the given range, passes it toactionand returnstrue.booleanwithMemorySegmentSlices(long[] offsets, int length, int count, CheckedConsumer<MemorySegment[], IOException> action)
-
Method Details
-
withMemorySegmentSlice
boolean withMemorySegmentSlice(long offset, long length, CheckedConsumer<MemorySegment, IOException> action) throws IOExceptionIf a direct memory segment view is available for the given range, passes it toactionand returnstrue. Otherwise returnsfalsewithout invoking the action.The memory segment 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 inputlength- the number of bytes requestedaction- the action to perform with the memory segment- Returns:
trueif a segment was available and the action was invoked- Throws:
IOException
-
withMemorySegmentSlices
boolean withMemorySegmentSlices(long[] offsets, int length, int count, CheckedConsumer<MemorySegment[], IOException> action) throws IOExceptionBulk variant ofwithMemorySegmentSlice(long, long, org.elasticsearch.core.CheckedConsumer<java.lang.foreign.MemorySegment, java.io.IOException>). Resolvescountfile ranges to memory segments and invokes the action while all segments are valid. All ref-counting and resource management is handled internally.The memory segments 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 rangelength- byte length of each range (same for all)count- number of ranges to resolveaction- receives aMemorySegment[]where entryicorresponds tooffsets[i]- Returns:
trueif all ranges were available and the action was invoked;falseotherwise- Throws:
IOException
-
checkSlicesArgs
static boolean checkSlicesArgs(long[] offsets, int count) Validates theoffsetsandcountarguments forwithMemorySegmentSlices(long[], int, int, org.elasticsearch.core.CheckedConsumer<java.lang.foreign.MemorySegment[], java.io.IOException>). Throws on negative count or an undersized offsets array. Returnstrueif count is zero (caller should treat as a no-op),falseotherwise.
-