Package com.github.luben.zstd
Class ZstdDirectBufferCompressingStreamNoFinalizer
java.lang.Object
com.github.luben.zstd.ZstdDirectBufferCompressingStreamNoFinalizer
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private int
private byte[]
private ZstdDictCompress
private boolean
private int
private int
private final long
private ByteBuffer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
compress
(ByteBuffer source) private long
compressDirectByteBuffer
(long ctx, ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize) private static long
private long
endStream
(long ctx, ByteBuffer dst, int dstOffset, int dstSize) void
flush()
protected ByteBuffer
flushBuffer
(ByteBuffer toFlush) This method should flush the buffer and either return the same buffer (but cleared) or a new buffer that should be used from then on.private long
flushStream
(long ctx, ByteBuffer dst, int dstOffset, int dstSize) private static long
freeCStream
(long ctx) private long
initCStream
(long ctx, int level) private long
initCStreamWithDict
(long ctx, byte[] dict, int dict_size, int level) private long
initCStreamWithFastDict
(long ctx, ZstdDictCompress dict) private static long
static int
setDict
(byte[] dict) setDict
(ZstdDictCompress dict)
-
Field Details
-
target
-
stream
private final long stream -
consumed
private int consumed -
produced
private int produced -
closed
private boolean closed -
initialized
private boolean initialized -
level
private int level -
dict
private byte[] dict -
fastDict
-
-
Constructor Details
-
ZstdDirectBufferCompressingStreamNoFinalizer
public ZstdDirectBufferCompressingStreamNoFinalizer(ByteBuffer target, int level) throws IOException - Throws:
IOException
-
-
Method Details
-
flushBuffer
This method should flush the buffer and either return the same buffer (but cleared) or a new buffer that should be used from then on.- Parameters:
toFlush
- buffer that has to be flushed (or most cases, you want to callByteBuffer.flip()
first)- Returns:
- the new buffer to use, for most cases the same as the one passed in, after a call to
ByteBuffer.clear()
. - Throws:
IOException
-
recommendedOutputBufferSize
public static int recommendedOutputBufferSize() -
recommendedCOutSize
private static long recommendedCOutSize() -
createCStream
private static long createCStream() -
freeCStream
private static long freeCStream(long ctx) -
initCStream
private long initCStream(long ctx, int level) -
initCStreamWithDict
private long initCStreamWithDict(long ctx, byte[] dict, int dict_size, int level) -
initCStreamWithFastDict
-
compressDirectByteBuffer
private long compressDirectByteBuffer(long ctx, ByteBuffer dst, int dstOffset, int dstSize, ByteBuffer src, int srcOffset, int srcSize) -
flushStream
-
endStream
-
setDict
- Throws:
IOException
-
setDict
public ZstdDirectBufferCompressingStreamNoFinalizer setDict(ZstdDictCompress dict) throws IOException - Throws:
IOException
-
compress
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-