Top Description Fields Constructors Methods
org.lwjgl.util.zstd

public Class Zstd

extends Object
Class Inheritance
Imports
javax.annotation.*, java.nio.*, org.lwjgl.system.*

Native bindings to Zstandard (zstd), a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios.

Introduction

zstd, short for Zstandard, is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios. The zstd compression library provides in-memory compression and decompression functions.

The library supports regular compression levels from 1 up to maxCLevel, which is currently 22. Levels ≥ 20, labeled --ultra, should be used with caution, as they require more memory. The library also offers negative compression levels, which extend the range of speed vs. ratio preferences. The lower the level, the faster the speed (at the cost of compression).

Compression can be done in:

The compression ratio achievable on small data can be highly improved using a dictionary. Dictionary compression can be performed in:

Advanced experimental functions can be accessed using #define ZSTD_STATIC_LINKING_ONLY before including zstd.h. Advanced experimental APIs should never be used with a dynamically-linked library. They are not "stable", their definitions or signatures may change in the future. Only static linking is allowed.

Streaming compression - HowTo

A ZSTD_CStream object is required to track streaming operation.

Use createCStream and freeCStream to create/release resources. ZSTD_CStream objects can be reused multiple times on consecutive compression operations. It is recommended to re-use ZSTD_CStream since it will play nicer with system's memory, by re-using already allocated memory.

For parallel execution, use one separate ZSTD_CStream.

Since v1.3.0, ZSTD_CStream and ZSTD_CCtx are the same thing.

Parameters are sticky: when starting a new compression on the same context, it will re-use the same sticky parameters as previous compression session. When in doubt, it's recommended to fully initialize the context before usage. Use CCtx_reset to reset the context and CCtx_setParameter, CCtx_setPledgedSrcSize, or CCtx_loadDictionary and friends to set more specific parameters, the pledged source size, or load a dictionary.

Use compressStream2 with e_continue as many times as necessary to consume input stream. The function will automatically update both pos fields within input and output. Note that the function may not consume the entire input, for example, because the output buffer is already full, in which case input.pos < input.size. The caller must check if input has been entirely consumed. If not, the caller must make some room to receive more compressed data, and then present again remaining input data.

Note

ZSTD_e_continue is guaranteed to make some forward progress when called, but doesn't guarantee maximal forward progress. This is especially relevant when compressing with multiple threads. The call won't block if it can consume some input, but if it can't it will wait for some, but not all, output to be flushed.

At any moment, it's possible to flush whatever data might remain stuck within internal buffer, using ZSTD_compressStream2() with e_flush. output->pos will be updated. Note that, if output->size is too small, a single invocation with ZSTD_e_flush might not be enough (return code > 0). In which case, make some room to receive more compressed data, and call again ZSTD_compressStream2() with ZSTD_e_flush. You must continue calling ZSTD_compressStream2() with ZSTD_e_flush until it returns 0, at which point you can change the operation.

Note

ZSTD_e_flush will flush as much output as possible, meaning when compressing with multiple threads, it will block until the flush is complete or the output buffer is full.

Calling ZSTD_compressStream2() with e_end instructs to finish a frame. It will perform a flush and write frame epilogue. The epilogue is required for decoders to consider a frame completed. Flush operation is the same, and follows same rules as calling ZSTD_compressStream2() with ZSTD_e_flush. You must continue calling ZSTD_compressStream2() with ZSTD_e_end until it returns 0, at which point you are free to start a new frame.

Note

ZSTD_e_end will flush as much output as possible, meaning when compressing with multiple threads, it will block until the flush is complete or the output buffer is full.

Streaming decompression - HowTo

A ZSTD_DStream object is required to track streaming operations.

Use createDStream and freeDStream to create/release resources. ZSTD_DStream objects can be re-used multiple times.

Use DCtx_reset and DCtx_refDDict to start a new decompression operation. Alternatively, use advanced API to set specific properties.

Use decompressStream repetitively to consume your input. The function will update both pos fields. If input.pos < input.size, some input has not been consumed. It's up to the caller to present again remaining data. The function tries to flush all data decoded immediately, respecting output buffer size. If output.pos < output.size, decoder has flushed everything it could. But if output.pos == output.size, there might be some data left within internal buffers. In which case, call ZSTD_decompressStream() again to flush whatever remains in the buffer.

Note

with no additional input provided, amount of data flushed is necessarily ≤ BLOCKSIZE_MAX.

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
ZSTD_btlazy2

Compression strategies, listed from fastest to strongest.

public static final int
ZSTD_btopt

Compression strategies, listed from fastest to strongest.

public static final int
ZSTD_btultra

Compression strategies, listed from fastest to strongest.

public static final int
ZSTD_btultra2

Compression strategies, listed from fastest to strongest.

public static final int
ZSTD_c_chainLog

Compression parameters.

public static final int
ZSTD_c_checksumFlag

Compression parameters.

public static final int
ZSTD_c_compressionLevel

Compression parameters.

public static final int
ZSTD_c_contentSizeFlag

Compression parameters.

public static final int
ZSTD_c_dictIDFlag

Compression parameters.

public static final int
ZSTD_c_enableLongDistanceMatching

Compression parameters.

public static final int
ZSTD_c_experimentalParam1

Compression parameters.

public static final int
ZSTD_c_experimentalParam10

Compression parameters.

public static final int
ZSTD_c_experimentalParam11

Compression parameters.

public static final int
ZSTD_c_experimentalParam12

Compression parameters.

public static final int
ZSTD_c_experimentalParam13

Compression parameters.

public static final int
ZSTD_c_experimentalParam14

Compression parameters.

public static final int
ZSTD_c_experimentalParam15

Compression parameters.

public static final int
ZSTD_c_experimentalParam16

Compression parameters.

public static final int
ZSTD_c_experimentalParam17

Compression parameters.

public static final int
ZSTD_c_experimentalParam18

Compression parameters.

public static final int
ZSTD_c_experimentalParam19

Compression parameters.

public static final int
ZSTD_c_experimentalParam2

Compression parameters.

public static final int
ZSTD_c_experimentalParam3

Compression parameters.

public static final int
ZSTD_c_experimentalParam4

Compression parameters.

public static final int
ZSTD_c_experimentalParam5

Compression parameters.

public static final int
ZSTD_c_experimentalParam6

Compression parameters.

public static final int
ZSTD_c_experimentalParam7

Compression parameters.

public static final int
ZSTD_c_experimentalParam8

Compression parameters.

public static final int
ZSTD_c_experimentalParam9

Compression parameters.

public static final int
ZSTD_c_hashLog

Compression parameters.

public static final int
ZSTD_c_jobSize

Compression parameters.

public static final int
ZSTD_c_ldmBucketSizeLog

Compression parameters.

public static final int
ZSTD_c_ldmHashLog

Compression parameters.

public static final int
ZSTD_c_ldmHashRateLog

Compression parameters.

public static final int
ZSTD_c_ldmMinMatch

Compression parameters.

public static final int
ZSTD_c_minMatch

Compression parameters.

public static final int
ZSTD_c_nbWorkers

Compression parameters.

public static final int
ZSTD_c_overlapLog

Compression parameters.

public static final int
ZSTD_c_searchLog

Compression parameters.

public static final int
ZSTD_c_strategy

Compression parameters.

public static final int
ZSTD_c_targetLength

Compression parameters.

public static final int
ZSTD_c_windowLog

Compression parameters.

public static final int
ZSTD_CLEVEL_DEFAULT

Default compression level.

public static final long
public static final long
public static final int
ZSTD_d_experimentalParam1

The advanced API pushes parameters one by one into an existing DCtx context.

public static final int
ZSTD_d_experimentalParam2

The advanced API pushes parameters one by one into an existing DCtx context.

public static final int
ZSTD_d_experimentalParam3

The advanced API pushes parameters one by one into an existing DCtx context.

public static final int
ZSTD_d_experimentalParam4

The advanced API pushes parameters one by one into an existing DCtx context.

public static final int
ZSTD_d_experimentalParam5

The advanced API pushes parameters one by one into an existing DCtx context.

public static final int
ZSTD_d_windowLogMax

The advanced API pushes parameters one by one into an existing DCtx context.

public static final int
ZSTD_dfast

Compression strategies, listed from fastest to strongest.

public static final int
ZSTD_e_continue

ZSTD_EndDirective Enum values:

  • e_continue - collect more data, encoder decides when to output compressed result, for optimal compression ratio
  • e_flush - flush any data provided so far, it creates (at least) one new block, that can be decoded immediately on reception; frame will continue: any future data can still reference previously compressed data, improving compression.
  • e_end - flush any remaining data and close current frame. note that frame is only closed after compressed data is fully flushed (return value == 0). After that point, any additional data starts a new frame.

    Note

    each frame is independent (does not reference any content from previous frame).

public static final int
ZSTD_e_end

ZSTD_EndDirective Enum values:

  • e_continue - collect more data, encoder decides when to output compressed result, for optimal compression ratio
  • e_flush - flush any data provided so far, it creates (at least) one new block, that can be decoded immediately on reception; frame will continue: any future data can still reference previously compressed data, improving compression.
  • e_end - flush any remaining data and close current frame. note that frame is only closed after compressed data is fully flushed (return value == 0). After that point, any additional data starts a new frame.

    Note

    each frame is independent (does not reference any content from previous frame).

public static final int
ZSTD_e_flush

ZSTD_EndDirective Enum values:

  • e_continue - collect more data, encoder decides when to output compressed result, for optimal compression ratio
  • e_flush - flush any data provided so far, it creates (at least) one new block, that can be decoded immediately on reception; frame will continue: any future data can still reference previously compressed data, improving compression.
  • e_end - flush any remaining data and close current frame. note that frame is only closed after compressed data is fully flushed (return value == 0). After that point, any additional data starts a new frame.

    Note

    each frame is independent (does not reference any content from previous frame).

public static final int
ZSTD_fast

Compression strategies, listed from fastest to strongest.

public static final int
ZSTD_greedy

Compression strategies, listed from fastest to strongest.

public static final int
ZSTD_lazy

Compression strategies, listed from fastest to strongest.

public static final int
ZSTD_lazy2

Compression strategies, listed from fastest to strongest.

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
ZSTD_VERSION_MAJOR

Version number part.

public static final int
ZSTD_VERSION_MINOR

Version number part.

public static final int
ZSTD_VERSION_NUMBER

Version number.

public static final int
ZSTD_VERSION_RELEASE

Version number part.

public static final String
ZSTD_VERSION_STRING

Version string.

Constructor Summary

AccessConstructor and Description
protected
Zstd()

Method Summary

Modifier and TypeMethod and Description
public static native long
nZSTD_CCtx_loadDictionary(long cctx, long dict, long dictSize)

Unsafe version of: CCtx_loadDictionary

public static native long
nZSTD_CCtx_refCDict(long cctx, long cdict)

Unsafe version of: CCtx_refCDict

public static native long
nZSTD_CCtx_refPrefix(long cctx, long prefix, long prefixSize)

Unsafe version of: CCtx_refPrefix

public static native long
nZSTD_CCtx_reset(long cctx, int reset)

Unsafe version of: CCtx_reset

public static native long
nZSTD_CCtx_setParameter(long cctx, int param, int value)

Unsafe version of: CCtx_setParameter

public static native long
nZSTD_CCtx_setPledgedSrcSize(long cctx, long pledgedSrcSize)

Unsafe version of: CCtx_setPledgedSrcSize

public static native long
nZSTD_compress(long dst, long dstCapacity, long src, long srcSize, int compressionLevel)

Unsafe version of: compress

public static native long
nZSTD_compress2(long cctx, long dst, long dstCapacity, long src, long srcSize)

Unsafe version of: compress2

public static native long
nZSTD_compress_usingCDict(long cctx, long dst, long dstCapacity, long src, long srcSize, long cdict)

Unsafe version of: compress_usingCDict

public static native long
nZSTD_compress_usingDict(long ctx, long dst, long dstCapacity, long src, long srcSize, long dict, long dictSize, int compressionLevel)

Unsafe version of: compress_usingDict

public static native long
nZSTD_compressCCtx(long ctx, long dst, long dstCapacity, long src, long srcSize, int compressionLevel)

Unsafe version of: compressCCtx

public static native long
nZSTD_compressStream2(long cctx, long output, long input, int endOp)

Unsafe version of: compressStream2

public static native void
nZSTD_cParam_getBounds(int cParam, long __result)

Unsafe version of: cParam_getBounds

public static native long
nZSTD_createCDict(long dictBuffer, long dictSize, int compressionLevel)

Unsafe version of: createCDict

public static native long
nZSTD_createDDict(long dictBuffer, long dictSize)

Unsafe version of: createDDict

public static native long
nZSTD_DCtx_loadDictionary(long dctx, long dict, long dictSize)

Unsafe version of: DCtx_loadDictionary

public static native long
nZSTD_DCtx_refDDict(long dctx, long ddict)

Unsafe version of: DCtx_refDDict

public static native long
nZSTD_DCtx_refPrefix(long dctx, long prefix, long prefixSize)

Unsafe version of: DCtx_refPrefix

public static native long
nZSTD_DCtx_reset(long dctx, int reset)

Unsafe version of: DCtx_reset

public static native long
nZSTD_DCtx_setParameter(long dctx, int param, int value)

Unsafe version of: DCtx_setParameter

public static native long
nZSTD_decompress(long dst, long
is an upper bound of originalSize to regenerate. If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.
dstCapacity
,
long src, long
must be the exact size of some number of compressed and/or skippable frames
compressedSize
)

Unsafe version of: decompress

public static native long
nZSTD_decompress_usingDDict(long dctx, long dst, long dstCapacity, long src, long srcSize, long ddict)

Unsafe version of: decompress_usingDDict

public static native long
nZSTD_decompress_usingDict(long dctx, long dst, long dstCapacity, long src, long srcSize, long dict, long dictSize)

Unsafe version of: decompress_usingDict

public static native long
nZSTD_decompressDCtx(long ctx, long dst, long dstCapacity, long src, long srcSize)

Unsafe version of: decompressDCtx

public static native long
nZSTD_decompressStream(long zds, long output, long input)

Unsafe version of: decompressStream

public static native void
nZSTD_dParam_getBounds(int dParam, long __result)

Unsafe version of: dParam_getBounds

public static native long
nZSTD_findFrameCompressedSize(long src, long
must be ≥ first frame size
srcSize
)

Unsafe version of: findFrameCompressedSize

public static native int
nZSTD_getDictID_fromCDict(long cdict)

Unsafe version of: getDictID_fromCDict

public static native int
nZSTD_getDictID_fromDDict(long ddict)

Unsafe version of: getDictID_fromDDict

public static native int
nZSTD_getDictID_fromDict(long dict, long dictSize)

Unsafe version of: getDictID_fromDict

public static native int
nZSTD_getDictID_fromFrame(long src, long srcSize)

Unsafe version of: getDictID_fromFrame

public static native long
nZSTD_getErrorName(long code)

Unsafe version of: getErrorName

public static native long
nZSTD_getFrameContentSize(long src, long
must be at least as large as the frame header. Hint: any size ≥ FRAMEHEADERSIZE_MAX is large enough.
srcSize
)

Unsafe version of: getFrameContentSize

public static native int
nZSTD_isError(long code)

Unsafe version of: isError

public static native long
nZSTD_sizeof_CCtx(long cctx)

public static native long
nZSTD_sizeof_CDict(long cdict)

public static native long
public static native long
nZSTD_sizeof_DCtx(long dctx)

public static native long
nZSTD_sizeof_DDict(long ddict)

public static native long
public static native long
nZSTD_versionString()

Unsafe version of: versionString

public static long

Returns:

0, or an error code (which can be tested with isError).
ZSTD_CCtx_loadDictionary
(long cctx, ByteBuffer dict)

Creates an internal CDict from dict buffer.

public static long

Returns:

0, or an error code (which can be tested with isError).
ZSTD_CCtx_refCDict
(long cctx, long cdict)

References a prepared dictionary, to be used for all future compressed frames.

public static long

Returns:

0, or an error code (which can be tested with isError).
ZSTD_CCtx_refPrefix
(long cctx, ByteBuffer prefix)

References a prefix (single-usage dictionary) for next compressed frame.

public static long
ZSTD_CCtx_reset(long cctx, int reset)

There are 2 different things that can be reset, independently or jointly :

  • The session: will stop compressing current frame, and make CCtx ready to start a new one. Useful after an error, or to interrupt any ongoing compression. Any internal data not yet flushed is cancelled. Compression parameters and dictionary remain unchanged. They will be used to compress next frame. Resetting session never fails.
  • The parameters: changes all parameters back to "default". This also removes any reference to any dictionary or external sequence producer. Parameters can only be changed between 2 sessions (i.e. no compression is currently ongoing) otherwise the reset fails, and function returns an error value (which can betested using isError).
  • Both: similar to resetting the session, followed by resetting parameters.
public static long
public static long

Returns:

0, or an error code (which can be tested with isError).
ZSTD_CCtx_setPledgedSrcSize
(long cctx, long pledgedSrcSize)

Total input data size to be compressed as a single frame.

public static long

Returns:

compressed size written into dst (≤ dstCapacity), or an error code if it fails (which can be tested using isError).
ZSTD_compress
(ByteBuffer dst, ByteBuffer src, int compressionLevel)

Compresses src content as a single zstd compressed frame into already allocated dst.

public static long

Returns:

compressed size written into dst (≤ dstCapacity), or an error code if it fails (which can be tested using isError)
ZSTD_compress2
(long cctx, ByteBuffer dst, ByteBuffer src)

Behaves the same as compressCCtx, but compression parameters are set using the advanced API.

public static long
ZSTD_compress_usingCDict(long cctx, ByteBuffer dst, ByteBuffer src, long cdict)

Compression using a digested Dictionary.

public static long
ZSTD_compress_usingDict(long ctx, ByteBuffer dst, ByteBuffer src, ByteBuffer dict, int compressionLevel)

Compression at an explicit compression level using a Dictionary.

public static native long
ZSTD_compressBound(long srcSize)

Returns the maximum compressed size in worst case single-pass scenario.

public static long
ZSTD_COMPRESSBOUND(long srcSize)

Pure Java version of ZSTD_compressBound.

public static long
ZSTD_compressCCtx(long ctx, ByteBuffer dst, ByteBuffer src, int compressionLevel)

Same as compress, using an explicit ZSTD_CCtx.

public static long

Returns:

provides a minimum amount of data remaining to be flushed from internal buffers or an error code, which can be tested using isError.

If != 0, flush is not fully completed, there is still some data left within internal buffers. This is useful for e_flush, since in this case more flushes are necessary to empty all buffers. For e_end, == 0 when internal buffers are fully flushed and frame is completed.

- after a ZSTD_e_end directive, if internal buffer is not fully flushed (!= 0), only ZSTD_e_end or ZSTD_e_flush operations are allowed. Before starting a new compression job, or changing compression parameters, it is required to fully flush internal buffers.

ZSTD_compressStream2
(long cctx, ZSTDOutBuffer output, ZSTDInBuffer input, int endOp)

Behaves about the same as ZSTD_compressStream(), with additional control on end directive.

public static ZSTDBounds
public static native long
ZSTD_createCCtx()

Creates a compression context.

public static long
ZSTD_createCDict(ByteBuffer dictBuffer, int compressionLevel)

When compressing multiple messages or blocks using the same dictionary, it's recommended to digest the dictionary only once, since it's a costly operation.

public static native long
ZSTD_createCStream()

A ZSTD_CStream object is required to track streaming operation.

public static native long
ZSTD_createDCtx()

Creates a decompression context.

public static long
ZSTD_createDDict(ByteBuffer dictBuffer)

Creates a digested dictionary, ready to start decompression operation without startup delay.

public static native long
ZSTD_createDStream()

A ZSTD_DStream object is required to track streaming operations.

public static native long
ZSTD_CStreamInSize()

Returns the recommended size for input buffer.

public static native long
ZSTD_CStreamOutSize()

Returns the recommended size for output buffer.

public static long

Returns:

0, or an error code (which can be tested with ZSTD_isError())
ZSTD_DCtx_loadDictionary
(long dctx, ByteBuffer dict)

Create an internal DDict from dict buffer, to be used to decompress all future frames.

public static long

Returns:

0, or an error code (which can be tested with isError)
ZSTD_DCtx_refDDict
(long dctx, long ddict)

References a prepared dictionary, to be used to decompress next frames.

public static long

Returns:

0, or an error code (which can be tested with isError)
ZSTD_DCtx_refPrefix
(long dctx, ByteBuffer prefix)

References a prefix (single-usage dictionary) to decompress next frame.

public static long

Returns:

0, or an error code, which can be tested with isError
ZSTD_DCtx_reset
(long dctx, int reset)

Returns a DCtx to clean state.

public static long

Returns:

0, or an error code (which can be tested using isError)
ZSTD_DCtx_setParameter
(long dctx, int param, int value)

Set one compression parameter, selected by enum ZSTD_dParameter.

public static long

Returns:

the number of bytes decompressed into dst (≤ dstCapacity), or an errorCode if it fails (which can be tested using isError).
ZSTD_decompress
(ByteBuffer dst, ByteBuffer src)

public static long
ZSTD_decompress_usingDDict(long dctx, ByteBuffer dst, ByteBuffer src, long ddict)

Decompression using a digested Dictionary.

public static long
ZSTD_decompress_usingDict(long dctx, ByteBuffer dst, ByteBuffer src, ByteBuffer dict)

Decompression using a known Dictionary.

public static long
ZSTD_decompressDCtx(long ctx, ByteBuffer dst, ByteBuffer src)

Same as decompress, requires an allocated ZSTD_DCtx.

public static long

Returns:

0 when a frame is completely decoded and fully flushed, an error code, which can be tested using isError, any other value > 0, which means there is still some decoding to do to complete current frame. The return value is a suggested next input size (just a hint to improve latency) that will never request more than the remaining frame size.
ZSTD_decompressStream
(long zds, ZSTDOutBuffer output, ZSTDInBuffer input)

Use ZSTD_decompressStream() repetitively to consume your input.

public static native int
ZSTD_defaultCLevel()

Returns the default compression level, specified by CLEVEL_DEFAULT

public static ZSTDBounds
ZSTD_dParam_getBounds(int dParam, ZSTDBounds
returns a structure, ZSTD_bounds, which contains - an error status field, which must be tested using isError - both lower and upper bounds, inclusive
__result
)

All parameters must belong to an interval with lower and upper bounds, otherwise they will either trigger an error or be automatically clamped.

public static native long
ZSTD_DStreamInSize()

Returns the recommended size for input buffer.

public static native long
ZSTD_DStreamOutSize()

Returns the recommended size for output buffer.

public static long

Returns:

the compressed size of the first frame starting at src, suitable to pass as srcSize to decompress or similar, or an error code if input is invalid
ZSTD_findFrameCompressedSize
(ByteBuffer
should point to the start of a ZSTD frame or skippable frame
src
)

public static native long
ZSTD_freeCCtx(long
accepts NULL pointer
cctx
)

Frees memory allocated by createCCtx.

public static native long
ZSTD_freeCDict(long
accepts NULL pointer
CDict
)

Frees memory allocated by createCDict.

public static native long
ZSTD_freeCStream(long
accepts NULL pointer
zcs
)

Frees memory allocated by createCStream.

public static native long
ZSTD_freeDCtx(long
accepts NULL pointer
dctx
)

Frees memory allocated by createDCtx.

public static native long
ZSTD_freeDDict(long
accepts NULL pointer
ddict
)

Frees memory allocated with createDDict.

public static native long
ZSTD_freeDStream(long
accepts NULL pointer
zds
)

Frees memory allocated by createDStream.

public static int
ZSTD_getDictID_fromCDict(long cdict)

Provides the dictID of the dictionary loaded into cdict.

public static int

Returns:

if == 0, the dictionary is not conformant to Zstandard specification, or empty.

Non-conformant dictionaries can still be loaded, but as content-only dictionaries.

ZSTD_getDictID_fromDDict
(long ddict)

Provides the dictID of the dictionary loaded into ddict.

public static int

Returns:

if == 0, the dictionary is not conformant with Zstandard specification. It can still be loaded, but as a content-only dictionary.
ZSTD_getDictID_fromDict
(ByteBuffer dict)

Provides the dictID stored within dictionary.

public static int

Returns:

if == 0, the dictID could not be decoded. This could for one of the following reasons :
  • The frame does not require a dictionary to be decoded (most common case).
  • The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden piece of information.

    Note

    this use case also happens when using a non-conformant dictionary.

  • srcSize is too small, and as a result, the frame header could not be decoded (only possible if srcSize < FRAMEHEADERSIZE_MAX).
  • This is not a Zstandard frame. When identifying the exact failure cause, it's possible to use getFrameHeader, which will provide a more precise error code.
ZSTD_getDictID_fromFrame
(ByteBuffer src)

Provides the dictID required to decompressed the frame stored within src.

public static String
ZSTD_getErrorName(long code)

Provides readable string from an error code.

public static long

Returns:

decompressed size of src frame content, if known
ZSTD_getFrameContentSize
(ByteBuffer
should point to the start of a ZSTD encoded frame
src
)

Notes:

  1. a 0 return value means the frame is valid but "empty"
  2. decompressed size is an optional field, it may not be present, typically in streaming mode. When return==ZSTD_CONTENTSIZE_UNKNOWN, data to decompress could be any size. In which case, it's necessary to use streaming mode to decompress data. Optionally, application can rely on some implicit limit, as decompress only needs an upper bound of decompressed size. (For example, data could be necessarily cut into blocks ≤ 16 KB).
  3. decompressed size is always present when compression is completed using single-pass functions, such as compress, compressCCtx, compress_usingDict or compress_usingCDict.
  4. decompressed size can be very large (64-bits value), potentially larger than what local system can handle as a single memory segment. In which case, it's necessary to use streaming mode to decompress data.
  5. If source is untrusted, decompressed size could be wrong or intentionally modified. Always ensure return value fits within application's authorized limits. Each application can set its own limits.
public static boolean
ZSTD_isError(long code)

Tells if a size_t function result is an error code.

public static native int
ZSTD_maxCLevel()

Returns the maximum compression level available.

public static native int
ZSTD_minCLevel()

Returns the minimum compression level available.

public static long
ZSTD_sizeof_CCtx(long cctx)

public static long
ZSTD_sizeof_CDict(long cdict)

public static long
public static long
ZSTD_sizeof_DCtx(long dctx)

public static long
ZSTD_sizeof_DDict(long ddict)

public static long
public static native int
ZSTD_versionNumber()

Returns runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE).

public static String
ZSTD_versionString()

Returns runtime library version, like "1.4.5".

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait