public class ZstdCompressCtx
extends java.lang.Object
| Constructor and Description |
|---|
ZstdCompressCtx()
Create a context for faster compress operations
One such context is required for each thread - put this in a ThreadLocal.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
byte[] |
compress(byte[] src) |
int |
compress(byte[] dst,
byte[] src) |
java.nio.ByteBuffer |
compress(java.nio.ByteBuffer srcBuf)
Compresses the data in buffer 'srcBuf'
|
int |
compress(java.nio.ByteBuffer dstBuf,
java.nio.ByteBuffer srcBuf)
Compresses the data in buffer 'srcBuf'
|
int |
compressByteArray(byte[] dstBuff,
int dstOffset,
int dstSize,
byte[] srcBuff,
int srcOffset,
int srcSize)
Compresses byte array 'srcBuff' into byte array 'dstBuff' reusing this ZstdCompressCtx.
|
int |
compressDirectByteBuffer(java.nio.ByteBuffer dstBuff,
int dstOffset,
int dstSize,
java.nio.ByteBuffer srcBuff,
int srcOffset,
int srcSize)
Compresses buffer 'srcBuff' into buffer 'dstBuff' reusing this ZstdCompressCtx.
|
protected void |
finalize() |
ZstdCompressCtx |
loadDict(byte[] dict)
Load compression dictionary to be used for subsequently compressed frames.
|
ZstdCompressCtx |
loadDict(ZstdDictCompress dict)
Load compression dictionary to be used for subsequently compressed frames.
|
ZstdCompressCtx |
setChecksum(boolean checksumFlag)
Enable or disable compression checksums
|
ZstdCompressCtx |
setContentSize(boolean contentSizeFlag)
Enable or disable content size
|
ZstdCompressCtx |
setDictID(boolean dictIDFlag)
Enable or disable dictID
|
void |
setFinalize(boolean finalize)
Enable or disable class finalizers
If finalizers are disabled the responsibility fir calling the `close` method is on the consumer.
|
ZstdCompressCtx |
setLevel(int level)
Set compression level
|
public ZstdCompressCtx()
public ZstdCompressCtx setLevel(int level)
level - compression level, default: 3public ZstdCompressCtx setChecksum(boolean checksumFlag)
checksumFlag - A 32-bits checksum of content is written at end of frame, default: falsepublic ZstdCompressCtx setContentSize(boolean contentSizeFlag)
contentSizeFlag - Content size will be written into frame header _whenever known_, default: truepublic ZstdCompressCtx setDictID(boolean dictIDFlag)
dictIDFlag - When applicable, dictionary's ID is written into frame header, default: truepublic ZstdCompressCtx loadDict(ZstdDictCompress dict)
dict - the dictionary or `null` to remove loaded dictionarypublic ZstdCompressCtx loadDict(byte[] dict)
dict - the dictionary or `null` to remove loaded dictionarypublic int compressDirectByteBuffer(java.nio.ByteBuffer dstBuff,
int dstOffset,
int dstSize,
java.nio.ByteBuffer srcBuff,
int srcOffset,
int srcSize)
dstBuff - the destination buffer - must be directdstOffset - the start offset of 'dstBuff'dstSize - the size of 'dstBuff' (after 'dstOffset')srcBuff - the source buffer - must be directsrcOffset - the start offset of 'srcBuff'srcSize - the length of 'srcBuff' (after 'srcOffset')public int compressByteArray(byte[] dstBuff,
int dstOffset,
int dstSize,
byte[] srcBuff,
int srcOffset,
int srcSize)
dstBuff - the destination buffer (byte array)dstOffset - the start offset of 'dstBuff'dstSize - the size of 'dstBuff' (after 'dstOffset')srcBuff - the source buffer (byte array)srcOffset - the start offset of 'srcBuff'srcSize - the length of 'srcBuff' (after 'srcOffset')public int compress(java.nio.ByteBuffer dstBuf,
java.nio.ByteBuffer srcBuf)
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, its `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, its `position()` will be set to the initial `limit()`.
public java.nio.ByteBuffer compress(java.nio.ByteBuffer srcBuf)
throws ZstdException
srcBuf - the source buffer - must be direct. It is assumed that the `position()` of the
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, its `position()` will be set to its initial `limit()`.
ZstdExceptionpublic int compress(byte[] dst,
byte[] src)
public byte[] compress(byte[] src)
public void setFinalize(boolean finalize)
finalize - default `true` - finalizers are enabledpublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableprotected void finalize()
finalize in class java.lang.Object