Package com.github.luben.zstd
Class ZstdOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.github.luben.zstd.ZstdOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
OutputStream filter that compresses the data using Zstd compression
-
Field Summary
FieldsFields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsConstructorDescriptionZstdOutputStream
(OutputStream outStream) create a new compressing OutputStreamZstdOutputStream
(OutputStream outStream, int level) create a new compressing OutputStreamZstdOutputStream
(OutputStream outStream, int level, boolean closeFrameOnFlush) Deprecated.Use ZstdOutputStream() or ZstdOutputStream(level) and set the other params with the settersZstdOutputStream
(OutputStream outStream, int level, boolean closeFrameOnFlush, boolean useChecksums) Deprecated.Use ZstdOutputStream() or ZstdOutputStream(level) and set the other params with the settersZstdOutputStream
(OutputStream outStream, BufferPool bufferPool) create a new compressing OutputStreamZstdOutputStream
(OutputStream outStream, BufferPool bufferPool, int level) create a new compressing OutputStream -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected void
finalize()
void
flush()
Flushes the outputstatic long
setChecksum
(boolean useChecksums) Enable checksums for the compressed stream.setCloseFrameOnFlush
(boolean closeOnFlush) Enable closing the frame on flush.setDict
(byte[] dict) setDict
(ZstdDictCompress dict) void
setFinalize
(boolean finalize) Deprecated.If you don't rely on finalizers, use `ZstdOutputStreamNoFinalizer` instead.setLevel
(int level) Set the compression level.setLong
(int windowLog) Set the Long Distance Matching.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
-
inner
-
-
Constructor Details
-
ZstdOutputStream
@Deprecated public ZstdOutputStream(OutputStream outStream, int level, boolean closeFrameOnFlush, boolean useChecksums) throws IOException Deprecated.Use ZstdOutputStream() or ZstdOutputStream(level) and set the other params with the setters- Throws:
IOException
-
ZstdOutputStream
@Deprecated public ZstdOutputStream(OutputStream outStream, int level, boolean closeFrameOnFlush) throws IOException Deprecated.Use ZstdOutputStream() or ZstdOutputStream(level) and set the other params with the setters- Throws:
IOException
-
ZstdOutputStream
create a new compressing OutputStream- Parameters:
outStream
- the stream to wraplevel
- the compression level- Throws:
IOException
-
ZstdOutputStream
create a new compressing OutputStream- Parameters:
outStream
- the stream to wrap- Throws:
IOException
-
ZstdOutputStream
public ZstdOutputStream(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
-
ZstdOutputStream
create a new compressing OutputStream- Parameters:
outStream
- the stream to wrapbufferPool
- the pool to fetch and return buffers- Throws:
IOException
-
-
Method Details
-
setFinalize
Deprecated.If you don't rely on finalizers, use `ZstdOutputStreamNoFinalizer` instead.Enable or disable class finalizers If finalizers are disabled the responsibility fir calling the `close` method is on the consumer.- Parameters:
finalize
- default `true` - finalizers are enabled
-
finalize
-
recommendedCOutSize
public static long recommendedCOutSize() -
setChecksum
Enable checksums for the compressed stream. Default: false- Throws:
IOException
-
setLevel
Set the compression level. Default:Zstd.defaultCompressionLevel()
- Throws:
IOException
-
setLong
Set the Long Distance Matching. 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.- Throws:
IOException
-
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
-