Class Zstd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
static int
static int
static byte[]
compress
(byte[] src) Compresses the data in buffer 'src' using default compression levelstatic long
compress
(byte[] dst, byte[] src, byte[] dict, int level) Compresses buffer 'src' into buffer 'dst' with dictionary.static long
compress
(byte[] dst, byte[] src, int level) Compresses buffer 'src' into buffer 'dst'.static long
compress
(byte[] dst, byte[] src, int level, boolean checksumFlag) Compresses buffer 'src' into buffer 'dst'.static long
compress
(byte[] dst, byte[] src, ZstdDictCompress dict) static byte[]
compress
(byte[] src, int level) Compresses the data in buffer 'src'static byte[]
compress
(byte[] src, ZstdDictCompress dict) Compresses the data in buffer 'src'static ByteBuffer
compress
(ByteBuffer srcBuff, byte[] dict, int level) Compresses buffer 'src' into buffer 'dst' with dictionary.static ByteBuffer
compress
(ByteBuffer srcBuf, int level) Compresses the data in buffer 'srcBuf'static ByteBuffer
compress
(ByteBuffer srcBuff, ZstdDictCompress dict) Compresses buffer 'src' into buffer 'dst' with dictionary.static int
compress
(ByteBuffer dstBuf, ByteBuffer srcBuf) Compresses the data in buffer 'srcBuf' using default compression levelstatic int
compress
(ByteBuffer dstBuff, ByteBuffer srcBuff, byte[] dict, int level) Compresses buffer 'src' into buffer 'dst' with dictionary.static int
compress
(ByteBuffer dstBuf, ByteBuffer srcBuf, int level) static int
compress
(ByteBuffer dstBuf, ByteBuffer srcBuf, int level, boolean checksumFlag) Compresses the data in buffer 'srcBuf'static int
compress
(ByteBuffer dstBuff, ByteBuffer srcBuff, ZstdDictCompress dict) Compresses buffer 'src' into buffer 'dst' with dictionary.static long
compressBound
(long srcSize) Maximum size of the compressed datastatic long
compressByteArray
(byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize, int level) Compresses buffer 'src' into buffer 'dst'.static long
compressByteArray
(byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize, int level, boolean checksumFlag) Compresses buffer 'src' into buffer 'dst'.static long
compressDirectByteBuffer
(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, int level) Compresses direct buffer 'src' into direct buffer 'dst'.static long
compressDirectByteBuffer
(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, int level, boolean checksumFlag) Compresses direct buffer 'src' into direct buffer 'dst'.static long
compressDirectByteBufferFastDict
(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, ZstdDictCompress dict) Compresses buffer 'src' into buffer 'dst' with dictionary.static long
compressDirectByteBufferUsingDict
(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, byte[] dict, int level) Compresses direct byte buffer 'src' into direct byte buffer 'dst' with dictionary.static long
compressFastDict
(byte[] dst, int dstOffset, byte[] src, int srcOffset, int length, ZstdDictCompress dict) Compresses buffer 'src' into buffer 'dst' with dictionary.static long
compressFastDict
(byte[] dst, int dstOffset, byte[] src, int srcOffset, ZstdDictCompress dict) Compresses buffer 'src' into buffer 'dst' with dictionary.static long
compressUnsafe
(long dst, long dstSize, long src, long srcSize, int level) Compresses buffer 'src' into direct buffer 'dst'.static long
compressUnsafe
(long dst, long dstSize, long src, long srcSize, int level, boolean checksumFlag) Compresses buffer 'src' into direct buffer 'dst'.static long
compressUsingDict
(byte[] dst, byte[] src, byte[] dict, int level) Deprecated.Use compress(dst, src, dict, level) insteadstatic byte[]
compressUsingDict
(byte[] src, byte[] dict, int level) Compresses buffer 'src' with dictionary.static long
compressUsingDict
(byte[] dst, int dstOffset, byte[] src, int srcOffset, byte[] dict, int level) Compresses buffer 'src' into buffer 'dst' with dictionary.static long
compressUsingDict
(byte[] dst, int dstOffset, byte[] src, int srcOffset, int length, byte[] dict, int level) Compresses buffer 'src' into buffer 'dst' with dictionary.static long
decompress
(byte[] dst, byte[] src) Decompresses buffer 'src' into buffer 'dst'.static long
decompress
(byte[] dst, byte[] src, byte[] dict) Decompresses buffer 'src' into buffer 'dst' with dictionary.static byte[]
decompress
(byte[] src, byte[] dict, int originalSize) static byte[]
decompress
(byte[] src, int originalSize) Decompress datastatic byte[]
decompress
(byte[] src, ZstdDictDecompress dict, int originalSize) Decompress datastatic ByteBuffer
decompress
(ByteBuffer srcBuff, byte[] dict, int originalSize) Decompress datastatic ByteBuffer
decompress
(ByteBuffer srcBuf, int originalSize) Decompress datastatic ByteBuffer
decompress
(ByteBuffer srcBuff, ZstdDictDecompress dict, int originalSize) Decompress datastatic int
decompress
(ByteBuffer dstBuf, ByteBuffer srcBuf) Decompress datastatic int
decompress
(ByteBuffer dstBuff, ByteBuffer srcBuff, byte[] dict) Decompress datastatic int
decompress
(ByteBuffer dstBuff, ByteBuffer srcBuff, ZstdDictDecompress dict) Decompress datastatic long
decompressByteArray
(byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize) Decompresses buffer 'src' into buffer 'dst'.static long
decompressDirectByteBuffer
(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize) Decompresses direct buffer 'src' into direct buffer 'dst'.static long
decompressDirectByteBufferFastDict
(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, ZstdDictDecompress dict) Decompresses buffer 'src' into buffer 'dst' with dictionary.static long
decompressDirectByteBufferUsingDict
(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, byte[] dict) Decompresses buffer 'src' into buffer 'dst' with dictionary.static long
decompressedDirectByteBufferSize
(ByteBuffer src, int srcPosition, int srcSize) Return the original size of a compressed buffer (if known)static long
decompressedDirectByteBufferSize
(ByteBuffer src, int srcPosition, int srcSize, boolean magicless) Return the original size of a compressed buffer (if known)static long
decompressedSize
(byte[] src) Return the original size of a compressed buffer (if known)static long
decompressedSize
(byte[] src, int srcPosition) Return the original size of a compressed buffer (if known)static long
decompressedSize
(byte[] src, int srcPosition, int srcSize) Return the original size of a compressed buffer (if known)static long
decompressedSize
(byte[] src, int srcPosition, int srcSize, boolean magicless) Return the original size of a compressed buffer (if known)static long
decompressedSize
(ByteBuffer srcBuf) Return the original size of a compressed buffer (if known)private static long
decompressedSize0
(byte[] src, int srcPosition, int srcSize, boolean magicless) static long
decompressFastDict
(byte[] dst, int dstOffset, byte[] src, int srcOffset, int length, ZstdDictDecompress dict) Decompresses buffer 'src' into buffer 'dst' with dictionary.static long
decompressUnsafe
(long dst, long dstSize, long src, long srcSize) Decompresses buffer 'src' into direct buffer 'dst'.static long
decompressUsingDict
(byte[] dst, byte[] src, byte[] dict) Deprecated.Use decompress(dst, src, dict) insteadstatic long
decompressUsingDict
(byte[] dst, int dstOffset, byte[] src, int srcOffset, int length, byte[] dict) Decompresses buffer 'src' into buffer 'dst' with dictionary.static int
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
static long
(package private) static final byte[]
extractArray
(ByteBuffer buffer) static long
getDictIdFromDict
(byte[] dict) Get DictId of a dictionarystatic long
getDictIdFromFrame
(byte[] src) Get DictId from a compressed framestatic long
Get DictId from a compressed ByteBuffer framestatic long
getErrorCode
(long code) static String
getErrorName
(long code) static int
static int
static boolean
isError
(long code) Error handlingstatic int
loadDictCompress
(long stream, byte[] dict, int dict_size) static int
loadDictDecompress
(long stream, byte[] dict, int dict_size) static int
loadFastDictCompress
(long stream, ZstdDictCompress dict) static int
loadFastDictDecompress
(long stream, ZstdDictDecompress dict) static int
static int
static int
static int
static int
static int
static int
static int
setCompressionChecksums
(long stream, boolean useChecksums) static int
setCompressionLevel
(long stream, int level) static int
setCompressionLong
(long stream, int windowLog) static int
setCompressionMagicless
(long stream, boolean useMagicless) static int
setCompressionWorkers
(long stream, int workers) static int
setDecompressionLongMax
(long stream, int windowLogMax) static int
setDecompressionMagicless
(long stream, boolean useMagicless) static long
trainFromBuffer
(byte[][] samples, byte[] dictBuffer) Creates a new dictionary to tune a kind of samples (uses Cover algorithm)static long
trainFromBuffer
(byte[][] samples, byte[] dictBuffer, boolean legacy) Creates a new dictionary to tune a kind of samplesstatic long
trainFromBufferDirect
(ByteBuffer samples, int[] sampleSizes, ByteBuffer dictBuffer) Creates a new dictionary to tune a kind of samples (uses Cover algorithm)static long
trainFromBufferDirect
(ByteBuffer samples, int[] sampleSizes, ByteBuffer dictBuffer, boolean legacy) Creates a new dictionary to tune a kind of samplesstatic int
static int
-
Constructor Details
-
Zstd
public Zstd()
-
-
Method Details
-
compress
public static long compress(byte[] dst, byte[] src, int level, boolean checksumFlag) Compresses buffer 'src' into buffer 'dst'. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination buffersrc
- the source bufferlevel
- compression levelchecksumFlag
- flag to enable or disable checksum- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compress
public static long compress(byte[] dst, byte[] src, int level) Compresses buffer 'src' into buffer 'dst'. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination buffersrc
- the source bufferlevel
- compression level- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compressByteArray
public static long compressByteArray(byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize, int level, boolean checksumFlag) Compresses buffer 'src' into buffer 'dst'. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination bufferdstOffset
- offset from the start of the destination bufferdstSize
- available space in the destination buffer after the offsetsrc
- the source buffersrcOffset
- offset from the start of the source buffersrcSize
- available data in the source buffer after the offsetlevel
- compression levelchecksumFlag
- flag to enable or disable checksum- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compressByteArray
public static long compressByteArray(byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize, int level) Compresses buffer 'src' into buffer 'dst'. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination bufferdstOffset
- offset from the start of the destination bufferdstSize
- available space in the destination buffer after the offsetsrc
- the source buffersrcOffset
- offset from the start of the source buffersrcSize
- available data in the source buffer after the offsetlevel
- compression level- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compressDirectByteBuffer
public static long compressDirectByteBuffer(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, int level, boolean checksumFlag) Compresses direct buffer 'src' into direct buffer 'dst'. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination bufferdstOffset
- offset from the start of the destination bufferdstSize
- available space in the destination buffer after the offsetsrc
- the source buffersrcOffset
- offset from the start of the source buffersrcSize
- available data in the source buffer after the offsetlevel
- compression levelchecksumFlag
- flag to enable or disable checksum- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compressDirectByteBuffer
public static long compressDirectByteBuffer(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, int level) Compresses direct buffer 'src' into direct buffer 'dst'. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination bufferdstOffset
- offset from the start of the destination bufferdstSize
- available space in the destination buffer after the offsetsrc
- the source buffersrcOffset
- offset from the start of the source buffersrcSize
- available data in the source buffer after the offsetlevel
- compression level- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compressUnsafe
public static long compressUnsafe(long dst, long dstSize, long src, long srcSize, int level, boolean checksumFlag) Compresses buffer 'src' into direct buffer 'dst'. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- pointer to the destination bufferdstSize
- available space in the destination buffersrc
- pointer to the source buffersrcSize
- available data in the source bufferlevel
- compression levelchecksumFlag
- flag to enable or disable checksum- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compressUnsafe
public static long compressUnsafe(long dst, long dstSize, long src, long srcSize, int level) Compresses buffer 'src' into direct buffer 'dst'. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- pointer to the destination bufferdstSize
- available space in the destination buffersrc
- pointer to the source buffersrcSize
- available data in the source bufferlevel
- compression level- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compressUsingDict
public static long compressUsingDict(byte[] dst, int dstOffset, byte[] src, int srcOffset, int length, byte[] dict, int level) Compresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination bufferdstOffset
- the start offset of 'dst'src
- the source buffersrcOffset
- the start offset of 'src'length
- the length of available data in 'src' after `srcOffset'dict
- the dictionary bufferlevel
- compression level- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compressUsingDict
public static long compressUsingDict(byte[] dst, int dstOffset, byte[] src, int srcOffset, byte[] dict, int level) Compresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination bufferdstOffset
- the start offset of 'dst'src
- the source buffersrcOffset
- the start offset of 'src'dict
- the dictionary bufferlevel
- compression level- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compressDirectByteBufferUsingDict
public static long compressDirectByteBufferUsingDict(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, byte[] dict, int level) Compresses direct byte buffer 'src' into direct byte buffer 'dst' with dictionary. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination bufferdstOffset
- the start offset of 'dst'dstSize
- size of 'dst'src
- the source buffersrcOffset
- the start offset of 'src'srcSize
- the length of 'src'dict
- the dictionary bufferlevel
- compression level- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compressFastDict
public static long compressFastDict(byte[] dst, int dstOffset, byte[] src, int srcOffset, int length, ZstdDictCompress dict) Compresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination bufferdstOffset
- the start offset of 'dst'src
- the source buffersrcOffset
- the start offset of 'src'length
- the length of available data in 'src' after `srcOffset'dict
- the dictionary- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compressFastDict
public static long compressFastDict(byte[] dst, int dstOffset, byte[] src, int srcOffset, ZstdDictCompress dict) Compresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination bufferdstOffset
- the start offset of 'dst'src
- the source buffersrcOffset
- the start offset of 'src'dict
- the dictionary- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compress
-
compressDirectByteBufferFastDict
public static long compressDirectByteBufferFastDict(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, ZstdDictCompress dict) Compresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination bufferdstOffset
- the start offset of 'dst'dstSize
- the size of 'dst'src
- the source buffersrcOffset
- the start offset of 'src'srcSize
- the length of 'src'dict
- the dictionary- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
decompress
public static long decompress(byte[] dst, byte[] src) Decompresses buffer 'src' into buffer 'dst'. Destination buffer should be sized to be larger of equal to the originalSize- Parameters:
dst
- the destination buffersrc
- the source buffer- Returns:
- the number of bytes decompressed into destination buffer (originalSize) or an errorCode if it fails (which can be tested using ZSTD_isError())
-
decompressByteArray
public static long decompressByteArray(byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize) Decompresses buffer 'src' into buffer 'dst'. Destination buffer should be sized to be larger of equal to the originalSize- Parameters:
dst
- the destination bufferdstOffset
- offset from the start of the destination bufferdstSize
- available space in the destination buffer after the offsetsrc
- the source buffersrcOffset
- offset from the start of the source buffersrcSize
- available data in the source buffer after the offset- Returns:
- the number of bytes decompressed into destination buffer (originalSize) or an errorCode if it fails (which can be tested using ZSTD_isError())
-
decompressDirectByteBuffer
public static long decompressDirectByteBuffer(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize) Decompresses direct buffer 'src' into direct buffer 'dst'. Destination buffer should be sized to be larger of equal to the originalSize- Parameters:
dst
- the destination bufferdstOffset
- offset from the start of the destination bufferdstSize
- available space in the destination buffer after the offsetsrc
- the source buffersrcOffset
- offset from the start of the source buffersrcSize
- available data in the source buffer after the offset- Returns:
- the number of bytes decompressed into destination buffer (originalSize) or an errorCode if it fails (which can be tested using ZSTD_isError())
-
decompressUnsafe
public static long decompressUnsafe(long dst, long dstSize, long src, long srcSize) Decompresses buffer 'src' into direct buffer 'dst'. Destination buffer should be sized to be larger of equal to the originalSize- Parameters:
dst
- pointer to the destination bufferdstSize
- available space in the destination buffer after the offsetsrc
- pointer the source buffersrcSize
- available data in the source buffer after the offset- Returns:
- the number of bytes decompressed into destination buffer (originalSize) or an errorCode if it fails (which can be tested using ZSTD_isError())
-
decompressUsingDict
public static long decompressUsingDict(byte[] dst, int dstOffset, byte[] src, int srcOffset, int length, byte[] dict) Decompresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to be larger of equal to the originalSize- Parameters:
dst
- the destination bufferdstOffset
- the start offset of 'dst'src
- the source buffersrcOffset
- the start offset of 'src'length
- the length of 'src'dict
- the dictionary buffer- Returns:
- the number of bytes decompressed into destination buffer (originalSize) or an errorCode if it fails (which can be tested using ZSTD_isError())
-
decompressDirectByteBufferUsingDict
public static long decompressDirectByteBufferUsingDict(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, byte[] dict) Decompresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to be larger of equal to the originalSize- Parameters:
dst
- the destination bufferdstOffset
- the start offset of 'dst'dstSize
- size of 'dst'src
- the source buffersrcOffset
- the start offset of 'src'srcSize
- the size of 'src'dict
- the dictionary buffer- Returns:
- the number of bytes decompressed into destination buffer (originalSize) or an errorCode if it fails (which can be tested using ZSTD_isError())
-
decompressFastDict
public static long decompressFastDict(byte[] dst, int dstOffset, byte[] src, int srcOffset, int length, ZstdDictDecompress dict) Decompresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to be larger of equal to the originalSize- Parameters:
dst
- the destination bufferdstOffset
- the start offset of 'dst'src
- the source buffersrcOffset
- the start offset of 'src'length
- the length of 'src'dict
- the dictionary- Returns:
- the number of bytes decompressed into destination buffer (originalSize) or an errorCode if it fails (which can be tested using ZSTD_isError())
-
decompressDirectByteBufferFastDict
public static long decompressDirectByteBufferFastDict(ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize, ZstdDictDecompress dict) Decompresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to be larger of equal to the originalSize- Parameters:
dst
- the destination bufferdstOffset
- the start offset of 'dst'dstSize
- the size of 'dst'src
- the source buffersrcOffset
- the start offset of 'src'srcSize
- the size of 'src'dict
- the dictionary- Returns:
- the number of bytes decompressed into destination buffer (originalSize) or an errorCode if it fails (which can be tested using ZSTD_isError())
-
loadDictDecompress
public static int loadDictDecompress(long stream, byte[] dict, int dict_size) -
loadFastDictDecompress
-
loadDictCompress
public static int loadDictCompress(long stream, byte[] dict, int dict_size) -
loadFastDictCompress
-
setCompressionChecksums
public static int setCompressionChecksums(long stream, boolean useChecksums) -
setCompressionMagicless
public static int setCompressionMagicless(long stream, boolean useMagicless) -
setCompressionLevel
public static int setCompressionLevel(long stream, int level) -
setCompressionLong
public static int setCompressionLong(long stream, int windowLog) -
setCompressionWorkers
public static int setCompressionWorkers(long stream, int workers) -
setDecompressionLongMax
public static int setDecompressionLongMax(long stream, int windowLogMax) -
setDecompressionMagicless
public static int setDecompressionMagicless(long stream, boolean useMagicless) -
decompressedSize
public static long decompressedSize(byte[] src, int srcPosition, int srcSize, boolean magicless) Return the original size of a compressed buffer (if known)- Parameters:
src
- the compressed buffersrcPosition
- offset of the compressed data inside the src buffersrcSize
- length of the compressed data inside the src buffermagicless
- whether the buffer contains a magicless frame- Returns:
- the number of bytes of the original buffer 0 if the original size is not known
-
decompressedSize0
private static long decompressedSize0(byte[] src, int srcPosition, int srcSize, boolean magicless) -
decompressedSize
public static long decompressedSize(byte[] src, int srcPosition, int srcSize) Return the original size of a compressed buffer (if known)- Parameters:
src
- the compressed buffersrcPosition
- offset of the compressed data inside the src buffersrcSize
- length of the compressed data inside the src buffer- Returns:
- the number of bytes of the original buffer 0 if the original size is not known
-
decompressedSize
public static long decompressedSize(byte[] src, int srcPosition) Return the original size of a compressed buffer (if known)- Parameters:
src
- the compressed buffersrcPosition
- offset of the compressed data inside the src buffer- Returns:
- the number of bytes of the original buffer 0 if the original size is not known
-
decompressedSize
public static long decompressedSize(byte[] src) Return the original size of a compressed buffer (if known)- Parameters:
src
- the compressed buffer- Returns:
- the number of bytes of the original buffer 0 if the original size is not known
-
decompressedDirectByteBufferSize
public static long decompressedDirectByteBufferSize(ByteBuffer src, int srcPosition, int srcSize, boolean magicless) Return the original size of a compressed buffer (if known)- Parameters:
src
- the compressed buffersrcPosition
- offset of the compressed data inside the src buffersrcSize
- length of the compressed data inside the src buffemagicless
- whether the buffer contains a magicless frame- Returns:
- the number of bytes of the original buffer 0 if the original size is not known
-
decompressedDirectByteBufferSize
Return the original size of a compressed buffer (if known)- Parameters:
src
- the compressed buffersrcPosition
- offset of the compressed data inside the src buffersrcSize
- length of the compressed data inside the src buffe- Returns:
- the number of bytes of the original buffer 0 if the original size is not known
-
compressBound
public static long compressBound(long srcSize) Maximum size of the compressed data- Parameters:
srcSize
- the size of the data to be compressed- Returns:
- the maximum size of the compressed data
-
isError
public static boolean isError(long code) Error handling- Parameters:
code
- return code/size- Returns:
- if the return code signals an error
-
getErrorName
-
getErrorCode
public static long getErrorCode(long code) -
errNoError
public static long errNoError() -
errGeneric
public static long errGeneric() -
errPrefixUnknown
public static long errPrefixUnknown() -
errVersionUnsupported
public static long errVersionUnsupported() -
errFrameParameterUnsupported
public static long errFrameParameterUnsupported() -
errFrameParameterWindowTooLarge
public static long errFrameParameterWindowTooLarge() -
errCorruptionDetected
public static long errCorruptionDetected() -
errChecksumWrong
public static long errChecksumWrong() -
errDictionaryCorrupted
public static long errDictionaryCorrupted() -
errDictionaryWrong
public static long errDictionaryWrong() -
errDictionaryCreationFailed
public static long errDictionaryCreationFailed() -
errParameterUnsupported
public static long errParameterUnsupported() -
errParameterOutOfBound
public static long errParameterOutOfBound() -
errTableLogTooLarge
public static long errTableLogTooLarge() -
errMaxSymbolValueTooLarge
public static long errMaxSymbolValueTooLarge() -
errMaxSymbolValueTooSmall
public static long errMaxSymbolValueTooSmall() -
errStageWrong
public static long errStageWrong() -
errInitMissing
public static long errInitMissing() -
errMemoryAllocation
public static long errMemoryAllocation() -
errWorkSpaceTooSmall
public static long errWorkSpaceTooSmall() -
errDstSizeTooSmall
public static long errDstSizeTooSmall() -
errSrcSizeWrong
public static long errSrcSizeWrong() -
errDstBufferNull
public static long errDstBufferNull() -
trainFromBuffer
public static long trainFromBuffer(byte[][] samples, byte[] dictBuffer, boolean legacy) Creates a new dictionary to tune a kind of samples- Parameters:
samples
- the samples buffer arraydictBuffer
- the new dictionary bufferlegacy
- use the legacy training algorithm; otherwise cover- Returns:
- the number of bytes into buffer 'dictBuffer' or an error code if it fails (which can be tested using ZSTD_isError())
-
trainFromBufferDirect
public static long trainFromBufferDirect(ByteBuffer samples, int[] sampleSizes, ByteBuffer dictBuffer, boolean legacy) Creates a new dictionary to tune a kind of samples- Parameters:
samples
- the samples direct byte buffer arraysampleSizes
- java integer array of sizesdictBuffer
- the new dictionary buffer (preallocated direct byte buffer)legacy
- use the legacy training algorithm; oter- Returns:
- the number of bytes into buffer 'dictBuffer' or an error code if it fails (which can be tested using ZSTD_isError())
-
getDictIdFromFrame
public static long getDictIdFromFrame(byte[] src) Get DictId from a compressed frame- Parameters:
src
- compressed frame- Returns:
- DictId or 0 if not available
-
getDictIdFromFrameBuffer
Get DictId from a compressed ByteBuffer frame- Parameters:
src
- compressed frame- Returns:
- DictId or 0 if not available
-
getDictIdFromDict
public static long getDictIdFromDict(byte[] dict) Get DictId of a dictionary- Parameters:
dict
- dictionary- Returns:
- DictId or 0 if not available
-
trainFromBuffer
public static long trainFromBuffer(byte[][] samples, byte[] dictBuffer) Creates a new dictionary to tune a kind of samples (uses Cover algorithm)- Parameters:
samples
- the samples buffer arraydictBuffer
- the new dictionary buffer- Returns:
- the number of bytes into buffer 'dictBuffer' or an error code if it fails (which can be tested using ZSTD_isError())
-
trainFromBufferDirect
public static long trainFromBufferDirect(ByteBuffer samples, int[] sampleSizes, ByteBuffer dictBuffer) Creates a new dictionary to tune a kind of samples (uses Cover algorithm)- Parameters:
samples
- the samples direct byte buffer arraysampleSizes
- java integer array of sizesdictBuffer
- the new dictionary buffer (preallocated direct byte buffer)- Returns:
- the number of bytes into buffer 'dictBuffer' or an error code if it fails (which can be tested using ZSTD_isError())
-
magicNumber
public static int magicNumber() -
windowLogMin
public static int windowLogMin() -
windowLogMax
public static int windowLogMax() -
chainLogMin
public static int chainLogMin() -
chainLogMax
public static int chainLogMax() -
hashLogMin
public static int hashLogMin() -
hashLogMax
public static int hashLogMax() -
searchLogMin
public static int searchLogMin() -
searchLogMax
public static int searchLogMax() -
searchLengthMin
public static int searchLengthMin() -
searchLengthMax
public static int searchLengthMax() -
blockSizeMax
public static int blockSizeMax() -
defaultCompressionLevel
public static int defaultCompressionLevel() -
minCompressionLevel
public static int minCompressionLevel() -
maxCompressionLevel
public static int maxCompressionLevel() -
compress
public static byte[] compress(byte[] src) Compresses the data in buffer 'src' using default compression level- Parameters:
src
- the source buffer- Returns:
- byte array with the compressed data
-
compress
public static byte[] compress(byte[] src, int level) Compresses the data in buffer 'src'- Parameters:
src
- the source bufferlevel
- compression level- Returns:
- byte array with the compressed data
-
compress
Compresses the data in buffer 'srcBuf' using default compression level- Parameters:
dstBuf
- the destination buffer. must be direct. It is assumed that the position() of this buffer marks the offset at which the compressed data are to be written, and that the limit() of this buffer is the maximum compressed data size to allow.When this method returns successfully, dstBuf's position() will be set to its current position() plus the compressed size of the data.
srcBuf
- the source buffer. must be direct. It is assumed that the position() of this buffer marks the beginning of the uncompressed data to be compressed, and that the limit() of this buffer marks its end.When this method returns successfully, srcBuf's position() will be set to its limit().
- Returns:
- the size of the compressed data
-
compress
Compresses the data in buffer 'srcBuf'- Parameters:
dstBuf
- the destination buffer. must be direct. It is assumed that the position() of this buffer marks the offset at which the compressed data are to be written, and that the limit() of this buffer is the maximum compressed data size to allow.When this method returns successfully, dstBuf's position() will be set to its current position() plus the compressed size of the data.
srcBuf
- the source buffer. must be direct. It is assumed that the position() of this buffer marks the beginning of the uncompressed data to be compressed, and that the limit() of this buffer marks its end.When this method returns successfully, srcBuf's position() will be set to its limit().
level
- compression level- Returns:
- the size of the compressed data
-
compress
-
compress
Compresses the data in buffer 'srcBuf'- Parameters:
srcBuf
- the source buffer. must be direct. It is assumed that the position() of this buffer marks the beginning of the uncompressed data to be compressed, and that the limit() of this buffer marks its end.When this method returns successfully, srcBuf's position() will be set to its limit().
level
- compression level- Returns:
- A newly allocated direct ByteBuffer containing the compressed data.
-
compress
Compresses the data in buffer 'src'- Parameters:
src
- the source bufferdict
- dictionary to use- Returns:
- byte array with the compressed data
-
compressUsingDict
Deprecated.Use compress(dst, src, dict, level) insteadCompresses buffer 'src' into buffer 'dst' with dictionary. -
compressUsingDict
public static byte[] compressUsingDict(byte[] src, byte[] dict, int level) Compresses buffer 'src' with dictionary.- Parameters:
src
- the source bufferdict
- the dictionary bufferlevel
- compression level- Returns:
- compressed byte array
-
compress
public static long compress(byte[] dst, byte[] src, byte[] dict, int level) Compresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dst
- the destination buffersrc
- the source bufferdict
- the dictionary bufferlevel
- compression level- Returns:
- the number of bytes written into buffer 'dst' or an error code if it fails (which can be tested using ZSTD_isError())
-
compress
Compresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dstBuff
- the destination buffersrcBuff
- the source bufferdict
- the dictionary bufferlevel
- compression level- Returns:
- the number of bytes written into buffer 'dstBuff'
-
compress
Compresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
srcBuff
- the source bufferdict
- the dictionary bufferlevel
- compression level- Returns:
- compressed direct byte buffer
-
compress
Compresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
dstBuff
- the destination buffersrcBuff
- the source bufferdict
- the dictionary buffer- Returns:
- the number of bytes written into buffer 'dstBuff'
-
compress
Compresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to handle worst cases situations (input data not compressible). Worst case size evaluation is provided by function ZSTD_compressBound().- Parameters:
srcBuff
- the source bufferdict
- the dictionary buffer- Returns:
- compressed direct byte buffer
-
decompress
public static byte[] decompress(byte[] src, int originalSize) Decompress data- Parameters:
src
- the source bufferoriginalSize
- the maximum size of the uncompressed data. If originaSize is greater than the actuall uncompressed size, additional memory copy going to happen. If originalSize is smaller than the uncompressed size, ZstdExeption will be thrown.- Returns:
- byte array with the decompressed data
-
decompress
Decompress data- Parameters:
dstBuf
- the destination buffer. must be direct. It is assumed that the position() of this buffer marks the offset at which the decompressed data are to be written, and that the limit() of this buffer is the maximum decompressed data size to allow.When this method returns successfully, dstBuf's position() will be set to its current position() plus the decompressed size of the data.
srcBuf
- the source buffer. must be direct. It is assumed that the position() of this buffer marks the beginning of the compressed data to be decompressed, and that the limit() of this buffer marks its end.When this method returns successfully, srcBuf's position() will be set to its limit().
- Returns:
- the size of the decompressed data.
-
decompress
Decompress data- Parameters:
srcBuf
- the source buffer. must be direct. It is assumed that the position() of this buffer marks the beginning of the compressed data to be decompressed, and that the limit() of this buffer marks its end.When this method returns successfully, srcBuf's position() will be set to its limit().
originalSize
- the maximum size of the uncompressed data- Returns:
- A newly-allocated ByteBuffer containing the decompressed data. The position() of this buffer will be 0, and the limit() will be the size of the decompressed data. In other words the buffer is ready to be used for reading. Note that this is different behavior from the other decompress() overload which takes as a parameter the destination ByteBuffer.
-
decompress
Decompress data- Parameters:
src
- the source bufferdict
- dictionary to useoriginalSize
- the maximum size of the uncompressed data- Returns:
- byte array with the decompressed data
-
decompressUsingDict
Deprecated.Use decompress(dst, src, dict) insteadDecompresses buffer 'src' into buffer 'dst' with dictionary. -
decompress
public static long decompress(byte[] dst, byte[] src, byte[] dict) Decompresses buffer 'src' into buffer 'dst' with dictionary. Destination buffer should be sized to be larger of equal to the originalSize- Parameters:
dst
- the destination buffersrc
- the source bufferdict
- the dictionary buffer- Returns:
- the number of bytes decompressed into destination buffer (originalSize) or an errorCode if it fails (which can be tested using ZSTD_isError())
-
decompress
public static byte[] decompress(byte[] src, byte[] dict, int originalSize) - Parameters:
src
- the source bufferdict
- dictionary to useoriginalSize
- the maximum size of the uncompressed data- Returns:
- byte array with the decompressed data
-
decompressedSize
Return the original size of a compressed buffer (if known)- Parameters:
srcBuf
- the compressed buffer. must be direct. It is assumed that the position() of this buffer marks the beginning of the compressed data whose decompressed size is being queried, and that the limit() of this buffer marks its end.- Returns:
- the number of bytes of the original buffer 0 if the original size is not known
-
decompress
Decompress data- Parameters:
dstBuff
- the destination buffer. must be direct. It is assumed that the position() of this buffer marks the offset at which the decompressed data are to be written, and that the limit() of this buffer is the maximum decompressed data size to allow.When this method returns successfully, dstBuff's position() will be set to its current position() plus the decompressed size of the data.
srcBuff
- the source buffer. must be direct. It is assumed that the position() of this buffer marks the beginning of the compressed data to be decompressed, and that the limit() of this buffer marks its end.When this method returns successfully, srcBuff's position() will be set to its limit().
dict
- the dictionary buffer to use for compression- Returns:
- the size of the decompressed data.
-
decompress
Decompress data- Parameters:
srcBuff
- the source buffer. must be direct. It is assumed that the position() of this buffer marks the beginning of the compressed data to be decompressed, and that the limit() of this buffer marks its end.When this method returns successfully, srcBuff's position() will be set to its limit().
dict
- the dictionary used in the compressionoriginalSize
- the maximum size of the uncompressed data- Returns:
- A newly-allocated ByteBuffer containing the decompressed data. The position() of this buffer will be 0, and the limit() will be the size of the decompressed data. In other words the buffer is ready to be used for reading. Note that this is different behavior from the other decompress() overload which takes as a parameter the destination ByteBuffer.
-
decompress
Decompress data- Parameters:
dstBuff
- the destination buffer. must be direct. It is assumed that the position() of this buffer marks the offset at which the decompressed data are to be written, and that the limit() of this buffer is the maximum decompressed data size to allow.When this method returns successfully, dstBuff's position() will be set to its current position() plus the decompressed size of the data.
srcBuff
- the source buffer. must be direct. It is assumed that the position() of this buffer marks the beginning of the compressed data to be decompressed, and that the limit() of this buffer marks its end.When this method returns successfully, srcBuff's position() will be set to its limit().
dict
- the dictionary buffer to use for compression- Returns:
- the size of the decompressed data.
-
decompress
Decompress data- Parameters:
srcBuff
- the source buffer. must be direct. It is assumed that the position() of this buffer marks the beginning of the compressed data to be decompressed, and that the limit() of this buffer marks its end.When this method returns successfully, srcBuff's position() will be set to its limit().
dict
- the dictionary used in the compressionoriginalSize
- the maximum size of the uncompressed data- Returns:
- A newly-allocated ByteBuffer containing the decompressed data. The position() of this buffer will be 0, and the limit() will be the size of the decompressed data. In other words the buffer is ready to be used for reading. Note that this is different behavior from the other decompress() overload which takes as a parameter the destination ByteBuffer.
-
extractArray
-