Package com.github.luben.zstd
Class ZstdDecompressCtx
java.lang.Object
com.github.luben.zstd.ZstdDecompressCtx
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a context for faster compress operations One such context is required for each thread - put this in a ThreadLocal. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intdecompress(byte[] dst, byte[] src) byte[]decompress(byte[] src, int originalSize) Decompress databyte[]decompress(byte[] src, int srcOffset, int srcSize, int originalSize) Decompress dataintdecompress(byte[] dst, ByteBuffer srcBuf) intdecompress(ByteBuffer dstBuf, byte[] src) decompress(ByteBuffer srcBuf, int originalSize) intdecompress(ByteBuffer dstBuf, ByteBuffer srcBuf) Decompresses buffer 'srcBuff' into buffer 'dstBuff' using this ZstdDecompressCtx.intdecompressByteArray(byte[] dstBuff, int dstOffset, int dstSize, byte[] srcBuff, int srcOffset, int srcSize) Decompresses byte array 'srcBuff' into byte array 'dstBuff' using this ZstdDecompressCtx.intdecompressByteArrayToDirectByteBuffer(ByteBuffer dstBuff, int dstOffset, int dstSize, byte[] srcBuff, int srcOffset, int srcSize) intdecompressDirectByteBuffer(ByteBuffer dstBuff, int dstOffset, int dstSize, ByteBuffer srcBuff, int srcOffset, int srcSize) Decompresses buffer 'srcBuff' into buffer 'dstBuff' using this ZstdDecompressCtx.booleanintdecompressDirectByteBufferToByteArray(byte[] dstBuff, int dstOffset, int dstSize, ByteBuffer srcBuff, int srcOffset, int srcSize) loadDict(byte[] dict) Load decompression dictionary.loadDict(ZstdDictDecompress dict) Load decompression dictionaryvoidreset()Clear all state and parameters from the decompression context.setMagicless(boolean magiclessFlag) Enable or disable magicless frames
-
Constructor Details
-
ZstdDecompressCtx
public ZstdDecompressCtx()Create a context for faster compress operations One such context is required for each thread - put this in a ThreadLocal.
-
-
Method Details
-
setMagicless
Enable or disable magicless frames- Parameters:
magiclessFlag- A 32-bits checksum of content is written at end of frame, default: false
-
loadDict
Load decompression dictionary- Parameters:
dict- the dictionary or `null` to remove loaded dictionary
-
loadDict
Load decompression dictionary.- Parameters:
dict- the dictionary or `null` to remove loaded dictionary
-
reset
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. -
decompressDirectByteBufferStream
- Parameters:
dst- destination of uncompressed datasrc- buffer to decompress- Returns:
- true if all state has been flushed from internal buffers
-
decompressDirectByteBuffer
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- the destination buffer - must be directdstOffset- the start offset of 'dstBuff'dstSize- the size of 'dstBuff'srcBuff- the source buffer - must be directsrcOffset- the start offset of 'srcBuff'srcSize- the size of 'srcBuff'- Returns:
- the number of bytes decompressed into destination buffer (originalSize)
-
decompressByteArray
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- the destination bufferdstOffset- the start offset of 'dstBuff'dstSize- the size of 'dstBuff'srcBuff- the source buffersrcOffset- the start offset of 'srcBuff'srcSize- the size of 'srcBuff'- Returns:
- the number of bytes decompressed into destination buffer (originalSize)
-
decompressByteArrayToDirectByteBuffer
public int decompressByteArrayToDirectByteBuffer(ByteBuffer dstBuff, int dstOffset, int dstSize, byte[] srcBuff, int srcOffset, int srcSize) -
decompressDirectByteBufferToByteArray
public int decompressDirectByteBufferToByteArray(byte[] dstBuff, int dstOffset, int dstSize, ByteBuffer srcBuff, int srcOffset, int srcSize) -
decompress
Decompresses buffer 'srcBuff' into buffer 'dstBuff' using this ZstdDecompressCtx.Destination buffer should be sized to be larger of equal to the originalSize.
- 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, its `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, its `position()` will be set to the initial `limit()`.
- Returns:
- the size of the decompressed data.
- Throws:
ZstdException
-
decompress
- Throws:
ZstdException
-
decompress
- Throws:
ZstdException
-
decompress
- Throws:
ZstdException
-
decompress
public int decompress(byte[] dst, byte[] src) -
decompress
Decompress data- Parameters:
src- the source bufferoriginalSize- the maximum size of the uncompressed data. If originalSize is greater than the actual uncompressed size, additional memory copy going to happen. If originalSize is smaller than the uncompressed size,ZstdExceptionwill be thrown.- Returns:
- byte array with the decompressed data
- Throws:
ZstdException
-
decompress
public byte[] decompress(byte[] src, int srcOffset, int srcSize, int originalSize) throws ZstdException Decompress data- Parameters:
src- the source buffersrcOffset- the start offset of 'src'srcSize- the size of 'src'originalSize- the maximum size of the uncompressed data. If originalSize is greater than the actual uncompressed size, additional memory copy going to happen. If originalSize is smaller than the uncompressed size,ZstdExceptionwill be thrown.- Returns:
- byte array with the decompressed data
- Throws:
ZstdException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-