java.lang.Object
org.elasticsearch.nativeaccess.Zstd
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classStreaming-mode zstd decompression resource. -
Method Summary
Modifier and TypeMethodDescriptionintcompress(byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize, int level) One-shot heapbyte[]compress at the given zstd compressionlevel.intcompress(CloseableByteBuffer dst, CloseableByteBuffer src, int level) Compress the content ofsrcintodstat compression levellevel, and return the number of compressed bytes.intcompressBound(int srcLen) Return the maximum number of compressed bytes given an input length.intdecompress(byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize) One-shot heapbyte[]decompress for callers that already hold the full compressed frame in a Java array (e.g.intdecompress(MemorySegment dst, MemorySegment src) Decompress the content ofsrcintodst, and return the number of decompressed bytes.intdecompress(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize) DecompresssrcSizebytes starting atsrcOffsetof the directByteBuffersrcintodstSizebytes starting atdstOffsetof the directByteBufferdst, and return the number of decompressed bytes.intdecompress(CloseableByteBuffer dst, CloseableByteBuffer src) Decompress the content ofsrcintodst, and return the number of decompressed bytes.intRecommended size for the input buffer feedingZstd.DStream.decompress(byte[], int, int, byte[], int, int)(ZSTD_DStreamInSize).intRecommended size for the output buffer ofZstd.DStream.decompress(byte[], int, int, byte[], int, int)(ZSTD_DStreamOutSize).Allocate a streaming decompression context wrappingZSTD_DStream.
-
Method Details
-
compress
Compress the content ofsrcintodstat compression levellevel, and return the number of compressed bytes.Buffer.position()andBuffer.limit()of bothByteBuffers are left unmodified. -
decompress
Decompress the content ofsrcintodst, and return the number of decompressed bytes.Buffer.position()andBuffer.limit()of bothByteBuffers are left unmodified. -
decompress
Decompress the content ofsrcintodst, and return the number of decompressed bytes. Both segments may be native or heap-backed. On JDK 22+ heap segments are passed through the critical downcall without copying; on JDK 21 the fallback adapter stages them via a confined arena. -
decompress
public int decompress(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize) DecompresssrcSizebytes starting atsrcOffsetof the directByteBuffersrcintodstSizebytes starting atdstOffsetof the directByteBufferdst, and return the number of decompressed bytes. Both buffers must be direct.Buffer.position()andBuffer.limit()of both buffers are left unmodified — callers manage their own cursors. Suits external codec APIs that pass plainByteBuffers with explicit offsets/sizes (e.g. parquet-mr'sBytesInputDecompressor). -
decompress
public int decompress(byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize) One-shot heapbyte[]decompress for callers that already hold the full compressed frame in a Java array (e.g. parquet-mr'sBytesInputDecompressor#decompress(BytesInput,int)). Equivalent tocom.github.luben.zstd.Zstd.decompress(byte[], byte[])but routed through Panama FFI'scritical(true)downcall — the heap segments are passed through directly without an off-heap staging copy. Returns the number of decompressed bytes actually written intodst[dstOffset .. dstOffset+dstSize). -
compress
public int compress(byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize, int level) One-shot heapbyte[]compress at the given zstd compressionlevel. The caller must sizedstto at leastcompressBound(int)bytes forsrcSize; Parquet'sBytesInputCompressorsizes its output buffer based on libzstd's worst case. Returns the actual compressed length written intodst[dstOffset .. dstOffset+returned). -
compressBound
public int compressBound(int srcLen) Return the maximum number of compressed bytes given an input length. -
dStreamInSize
public int dStreamInSize()Recommended size for the input buffer feedingZstd.DStream.decompress(byte[], int, int, byte[], int, int)(ZSTD_DStreamInSize). The value is constant per libzstd build (≈ 128 KB on 1.5.7); callers typically cache it in astatic finalfield rather than calling per-stream. -
dStreamOutSize
public int dStreamOutSize()Recommended size for the output buffer ofZstd.DStream.decompress(byte[], int, int, byte[], int, int)(ZSTD_DStreamOutSize). Used only by theskip()scratch buffer in the wrapper — the regular read path writes straight into the caller's destination array. -
newDStream
Allocate a streaming decompression context wrappingZSTD_DStream. The returnedZstd.DStreamowns a native zstd context plus two small persistent struct holders; callZstd.DStream.close()(or use try-with-resources) to release them. Single-threaded by contract — do not share a singleZstd.DStreamacross threads.
-