Class ZstdHeapFallback
java.lang.Object
org.elasticsearch.nativeaccess.lib.ZstdHeapFallback
JDK 21
@Critical fallback for ZstdLibrary.compressHeap(java.lang.foreign.MemorySegment, long, java.lang.foreign.MemorySegment, long, int) / ZstdLibrary.decompressHeap(java.lang.foreign.MemorySegment, long, java.lang.foreign.MemorySegment, long).
On JDK 21 the raw libzstd downcall handle is linked without Linker.Option.critical(true) (the
option doesn't exist there), so it rejects heap-backed MemorySegment arguments. The annotation
processor wires @Critical(fallbackAdapter = ZstdHeapFallback.class) so that on JDK 21 each
compressHeap$mh / decompressHeap$mh field holds an adapter that points at the matching
method below: the heap input is staged into a confined Arena, the raw handle is invoked with
native segments, and the decoded length is copied back into the caller's heap output. On JDK 22+ this class
is not referenced.
-
Method Summary
Modifier and TypeMethodDescriptionstatic longcompressHeap(MethodHandle mh, MemorySegment dst, long dstCap, MemorySegment src, long srcSize, int level) static longdecompressHeap(MethodHandle mh, MemorySegment dst, long dstCap, MemorySegment src, long srcSize)
-
Method Details
-
compressHeap
public static long compressHeap(MethodHandle mh, MemorySegment dst, long dstCap, MemorySegment src, long srcSize, int level) throws Throwable - Throws:
Throwable
-
decompressHeap
public static long decompressHeap(MethodHandle mh, MemorySegment dst, long dstCap, MemorySegment src, long srcSize) throws Throwable - Throws:
Throwable
-