Package com.github.luben.zstd
Class ZstdOutputStreamNoFinalizer
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.github.luben.zstd.ZstdOutputStreamNoFinalizer
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
OutputStream filter that compresses the data using Zstd compression.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BufferPool
private boolean
private final byte[]
private final ByteBuffer
private long
private static final int
private boolean
private boolean
private long
private final long
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsConstructorDescriptionZstdOutputStreamNoFinalizer
(OutputStream outStream) create a new compressing OutputStreamZstdOutputStreamNoFinalizer
(OutputStream outStream, int level) create a new compressing OutputStreamZstdOutputStreamNoFinalizer
(OutputStream outStream, BufferPool bufferPool) create a new compressing OutputStreamZstdOutputStreamNoFinalizer
(OutputStream outStream, BufferPool bufferPool, int level) create a new compressing OutputStream -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
private void
close
(boolean closeParentStream) void
private int
compressStream
(long ctx, byte[] dst, int dst_size, byte[] src, int src_size) private static long
private int
endStream
(long ctx, byte[] dst, int dst_size) void
flush()
Flushes the outputprivate int
flushStream
(long ctx, byte[] dst, int dst_size) private static int
freeCStream
(long ctx) static long
private int
resetCStream
(long ctx) setChecksum
(boolean useChecksums) Enable checksums for the compressed stream.setCloseFrameOnFlush
(boolean closeOnFlush) Enable closing the frame on flush.setDict
(byte[] dict) setDict
(ZstdDictCompress dict) setLevel
(int level) Set the compression level.setLong
(int windowLog) Enable Long Distance Matching and set the Window size Log.setWorkers
(int n) Enable use of worker threads for parallel compression.void
write
(byte[] src, int offset, int len) void
write
(int i) Methods inherited from class java.io.FilterOutputStream
write
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
stream
private final long stream -
srcPos
private long srcPos -
dstPos
private long dstPos -
bufferPool
-
dstByteBuffer
-
dst
private final byte[] dst -
isClosed
private boolean isClosed -
dstSize
private static final int dstSize -
closeFrameOnFlush
private boolean closeFrameOnFlush -
frameClosed
private boolean frameClosed
-
-
Constructor Details
-
ZstdOutputStreamNoFinalizer
create a new compressing OutputStream- Parameters:
outStream
- the stream to wraplevel
- the compression level- Throws:
IOException
-
ZstdOutputStreamNoFinalizer
create a new compressing OutputStream- Parameters:
outStream
- the stream to wrap- Throws:
IOException
-
ZstdOutputStreamNoFinalizer
public ZstdOutputStreamNoFinalizer(OutputStream outStream, BufferPool bufferPool, int level) throws IOException create a new compressing OutputStream- Parameters:
outStream
- the stream to wrapbufferPool
- the pool to fetch and return buffers- Throws:
IOException
-
ZstdOutputStreamNoFinalizer
public ZstdOutputStreamNoFinalizer(OutputStream outStream, BufferPool bufferPool) throws IOException create a new compressing OutputStream- Parameters:
outStream
- the stream to wrapbufferPool
- the pool to fetch and return buffers- Throws:
IOException
-
-
Method Details
-
recommendedCOutSize
public static long recommendedCOutSize() -
createCStream
private static long createCStream() -
freeCStream
private static int freeCStream(long ctx) -
resetCStream
private int resetCStream(long ctx) -
compressStream
private int compressStream(long ctx, byte[] dst, int dst_size, byte[] src, int src_size) -
flushStream
private int flushStream(long ctx, byte[] dst, int dst_size) -
endStream
private int endStream(long ctx, byte[] dst, int dst_size) -
setChecksum
Enable checksums for the compressed stream. Default: false- Throws:
IOException
-
setLevel
Set the compression level. Default:Zstd.defaultCompressionLevel()
- Throws:
IOException
-
setLong
Enable Long Distance Matching and set the Window size Log. Values for windowLog outside the range 10-27 will disable and reset LDM- Throws:
IOException
-
setWorkers
Enable use of worker threads for parallel compression. Default: no worker threads.- Throws:
IOException
-
setCloseFrameOnFlush
Enable closing the frame on flush. This will guarantee that it can be ready fully if the process crashes before closing the stream. On the downside it will negatively affect the compression ratio. Default: false. -
setDict
- Throws:
IOException
-
setDict
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
flush
Flushes the output- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFilterOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-
closeWithoutClosingParentStream
- Throws:
IOException
-
close
- Throws:
IOException
-