Top Fields Constructors Methods
com.github.luben.zstd

public Class ZstdDecompressCtx

extends AutoCloseBase
Class Inheritance
Imports
com.github.luben.zstd.util.Native, com.github.luben.zstd.ZstdDictDecompress, java.nio.ByteBuffer, java.util.Arrays

Field Summary

Modifier and TypeField and Description
private ZstdDictDecompress
private long

Constructor Summary

AccessConstructor and Description
public
ZstdDecompressCtx()

Create a context for faster compress operations One such context is required for each thread - put this in a ThreadLocal.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the size of the decompressed data.
decompress
(ByteBuffer
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, its `position()` will be set to its current `position()` plus the decompressed size of the data.

dstBuf
,
ByteBuffer
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, its `position()` will be set to the initial `limit()`.

srcBuf
)

Decompresses buffer 'srcBuff' into buffer 'dstBuff' using this ZstdDecompressCtx.

public ByteBuffer
decompress(ByteBuffer srcBuf, int originalSize)

public int
decompress(byte[] dst, byte[] src)

public byte[]

Returns:

byte array with the decompressed data
decompress
(byte[]
the source buffer
src
,
int
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.
originalSize
)

Decompress data

public int

Returns:

the number of bytes decompressed into destination buffer (originalSize)
decompressByteArray
(byte[]
the destination buffer
dstBuff
,
int
the start offset of 'dstBuff'
dstOffset
,
int
the size of 'dstBuff'
dstSize
,
byte[]
the source buffer
srcBuff
,
int
the start offset of 'srcBuff'
srcOffset
,
int
the size of 'srcBuff'
srcSize
)

Decompresses byte array 'srcBuff' into byte array 'dstBuff' using this ZstdDecompressCtx.

private static native long
decompressByteArray0(long nativePtr, byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize)

public int

Returns:

the number of bytes decompressed into destination buffer (originalSize)
decompressDirectByteBuffer
(ByteBuffer
the destination buffer - must be direct
dstBuff
,
int
the start offset of 'dstBuff'
dstOffset
,
int
the size of 'dstBuff'
dstSize
,
ByteBuffer
the source buffer - must be direct
srcBuff
,
int
the start offset of 'srcBuff'
srcOffset
,
int
the size of 'srcBuff'
srcSize
)

Decompresses buffer 'srcBuff' into buffer 'dstBuff' using this ZstdDecompressCtx.

private static native long
decompressDirectByteBuffer0(long nativePtr, ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize)

public boolean

Returns:

true if all state has been flushed from internal buffers
decompressDirectByteBufferStream
(ByteBuffer
destination of uncompressed data
dst
,
ByteBuffer
buffer to decompress
src
)

Decompress as much of the src ByteBuffer into the dst ByteBuffer as possible.

private static native long
decompressDirectByteBufferStream0(long nativePtr, ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize)

4 pieces of information are packed into the return value of this method, which must be treated as an unsigned long.

pack-priv void
private void
private static native void
free(long nativePtr)

private static native long
init()

private static native long
loadDDict0(long nativePtr, byte[] dict)

private static native long
loadDDictFast0(long nativePtr, ZstdDictDecompress dict)

public ZstdDecompressCtx
loadDict(ZstdDictDecompress
the dictionary or `null` to remove loaded dictionary
dict
)

Load decompression dictionary

public ZstdDecompressCtx
loadDict(byte[]
the dictionary or `null` to remove loaded dictionary
dict
)

Load decompression dictionary.

public void
reset()

Clear all state and parameters from the decompression context.

private static native void
reset0(long nativePtr)

public ZstdDecompressCtx
setMagicless(boolean
A 32-bits checksum of content is written at end of frame, default: false
magiclessFlag
)

Enable or disable magicless frames

Inherited from com.github.luben.zstd.AutoCloseBase:
acquireSharedLockclosereleaseSharedLockstoreFence

Field Detail

decompression_dictback to summary
private ZstdDictDecompress decompression_dict
nativePtrback to summary
private long nativePtr

Constructor Detail

ZstdDecompressCtxback to summary
public ZstdDecompressCtx()

Create a context for faster compress operations One such context is required for each thread - put this in a ThreadLocal.

Method Detail

decompressback to summary
public int decompress(ByteBuffer dstBuf, ByteBuffer srcBuf) throws ZstdException

Decompresses buffer 'srcBuff' into buffer 'dstBuff' using this ZstdDecompressCtx. Destination buffer should be sized to be larger of equal to the originalSize.

Parameters
dstBuf:ByteBuffer

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, its `position()` will be set to its current `position()` plus the decompressed size of the data.

srcBuf:ByteBuffer

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, its `position()` will be set to the initial `limit()`.

Returns:int

the size of the decompressed data.

decompressback to summary
public ByteBuffer decompress(ByteBuffer srcBuf, int originalSize) throws ZstdException
decompressback to summary
public int decompress(byte[] dst, byte[] src)
decompressback to summary
public byte[] decompress(byte[] src, int originalSize) throws ZstdException

Decompress data

Parameters
src:byte[]

the source buffer

originalSize:int

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[]

byte array with the decompressed data

decompressByteArrayback to summary
public int decompressByteArray(byte[] dstBuff, int dstOffset, int dstSize, byte[] srcBuff, int srcOffset, int srcSize)

Decompresses byte array 'srcBuff' into byte array 'dstBuff' using this ZstdDecompressCtx. Destination buffer should be sized to be larger of equal to the originalSize.

Parameters
dstBuff:byte[]

the destination buffer

dstOffset:int

the start offset of 'dstBuff'

dstSize:int

the size of 'dstBuff'

srcBuff:byte[]

the source buffer

srcOffset:int

the start offset of 'srcBuff'

srcSize:int

the size of 'srcBuff'

Returns:int

the number of bytes decompressed into destination buffer (originalSize)

decompressByteArray0back to summary
private static native long decompressByteArray0(long nativePtr, byte[] dst, int dstOffset, int dstSize, byte[] src, int srcOffset, int srcSize)
decompressDirectByteBufferback to summary
public int decompressDirectByteBuffer(ByteBuffer dstBuff, int dstOffset, int dstSize, ByteBuffer srcBuff, int srcOffset, int srcSize)

Decompresses buffer 'srcBuff' into buffer 'dstBuff' using this ZstdDecompressCtx. Destination buffer should be sized to be larger of equal to the originalSize. This is a low-level function that does not take into account or affect the `limit` or `position` of source or destination buffers.

Parameters
dstBuff:ByteBuffer

the destination buffer - must be direct

dstOffset:int

the start offset of 'dstBuff'

dstSize:int

the size of 'dstBuff'

srcBuff:ByteBuffer

the source buffer - must be direct

srcOffset:int

the start offset of 'srcBuff'

srcSize:int

the size of 'srcBuff'

Returns:int

the number of bytes decompressed into destination buffer (originalSize)

decompressDirectByteBuffer0back to summary
private static native long decompressDirectByteBuffer0(long nativePtr, ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize)
decompressDirectByteBufferStreamback to summary
public boolean decompressDirectByteBufferStream(ByteBuffer dst, ByteBuffer src)

Decompress as much of the src ByteBuffer into the dst ByteBuffer as possible.

Parameters
dst:ByteBuffer

destination of uncompressed data

src:ByteBuffer

buffer to decompress

Returns:boolean

true if all state has been flushed from internal buffers

decompressDirectByteBufferStream0back to summary
private static native long decompressDirectByteBufferStream0(long nativePtr, ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize)

4 pieces of information are packed into the return value of this method, which must be treated as an unsigned long. The highest bit is set if all data has been flushed from internal buffers. The next 31 bits are the new position of the destination buffer. The next bit is set if an error occurred. If an error occurred, the lowest 31 bits encode a zstd error code. Otherwise, the lowest 31 bits are the new position of the source buffer.

doCloseback to summary
pack-priv void doClose()

Implements abstract com.github.luben.zstd.AutoCloseBase.doClose.

ensureOpenback to summary
private void ensureOpen()
freeback to summary
private static native void free(long nativePtr)
initback to summary
private static native long init()
loadDDict0back to summary
private static native long loadDDict0(long nativePtr, byte[] dict)
loadDDictFast0back to summary
private static native long loadDDictFast0(long nativePtr, ZstdDictDecompress dict)
loadDictback to summary
public ZstdDecompressCtx loadDict(ZstdDictDecompress dict)

Load decompression dictionary

Parameters
dict:ZstdDictDecompress

the dictionary or `null` to remove loaded dictionary

loadDictback to summary
public ZstdDecompressCtx loadDict(byte[] dict)

Load decompression dictionary.

Parameters
dict:byte[]

the dictionary or `null` to remove loaded dictionary

resetback to summary
public void reset()

Clear all state and parameters from the decompression context. This leaves the object in a state identical to a newly created decompression context.

reset0back to summary
private static native void reset0(long nativePtr)
setMagiclessback to summary
public ZstdDecompressCtx setMagicless(boolean magiclessFlag)

Enable or disable magicless frames

Parameters
magiclessFlag:boolean

A 32-bits checksum of content is written at end of frame, default: false