Package com.github.luben.zstd
Class ZstdDirectBufferCompressingStreamNoFinalizer
- java.lang.Object
-
- com.github.luben.zstd.ZstdDirectBufferCompressingStreamNoFinalizer
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class ZstdDirectBufferCompressingStreamNoFinalizer extends java.lang.Object implements java.io.Closeable, java.io.Flushable
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
closed
private int
consumed
private byte[]
dict
private ZstdDictCompress
fastDict
private boolean
initialized
private int
level
private int
produced
private long
stream
private java.nio.ByteBuffer
target
-
Constructor Summary
Constructors Constructor Description ZstdDirectBufferCompressingStreamNoFinalizer(java.nio.ByteBuffer target, int level)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
compress(java.nio.ByteBuffer source)
private long
compressDirectByteBuffer(long ctx, java.nio.ByteBuffer dst, int dstOffset, int dstSize, java.nio.ByteBuffer src, int srcOffset, int srcSize)
private static long
createCStream()
private long
endStream(long ctx, java.nio.ByteBuffer dst, int dstOffset, int dstSize)
void
flush()
protected java.nio.ByteBuffer
flushBuffer(java.nio.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, java.nio.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
recommendedCOutSize()
static int
recommendedOutputBufferSize()
ZstdDirectBufferCompressingStreamNoFinalizer
setDict(byte[] dict)
ZstdDirectBufferCompressingStreamNoFinalizer
setDict(ZstdDictCompress dict)
-
-
-
Field Detail
-
target
private java.nio.ByteBuffer 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
private ZstdDictCompress fastDict
-
-
Method Detail
-
flushBuffer
protected java.nio.ByteBuffer flushBuffer(java.nio.ByteBuffer toFlush) throws java.io.IOException
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:
java.io.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
private long initCStreamWithFastDict(long ctx, ZstdDictCompress dict)
-
compressDirectByteBuffer
private long compressDirectByteBuffer(long ctx, java.nio.ByteBuffer dst, int dstOffset, int dstSize, java.nio.ByteBuffer src, int srcOffset, int srcSize)
-
flushStream
private long flushStream(long ctx, java.nio.ByteBuffer dst, int dstOffset, int dstSize)
-
endStream
private long endStream(long ctx, java.nio.ByteBuffer dst, int dstOffset, int dstSize)
-
setDict
public ZstdDirectBufferCompressingStreamNoFinalizer setDict(byte[] dict)
-
setDict
public ZstdDirectBufferCompressingStreamNoFinalizer setDict(ZstdDictCompress dict)
-
compress
public void compress(java.nio.ByteBuffer source) throws java.io.IOException
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-