Top Description Fields Constructors Methods
com.github.luben.zstd

public Class ZstdOutputStream

extends FilterOutputStream
Class Inheritance
Imports
java.io.OutputStream, .FilterOutputStream, .IOException, java.nio.ByteBuffer, com.github.luben.zstd.util.Native

OutputStream filter that compresses the data using Zstd compression

Field Summary

Modifier and TypeField and Description
private ZstdOutputStreamNoFinalizer
Inherited from java.io.FilterOutputStream:
out

Constructor Summary

AccessConstructor and Description
public
ZstdOutputStream(OutputStream outStream, int level, boolean closeFrameOnFlush, boolean useChecksums)

Deprecated Use ZstdOutputStream() or ZstdOutputStream(level) and set the other params with the setters
public
ZstdOutputStream(OutputStream outStream, int level, boolean closeFrameOnFlush)

Deprecated Use ZstdOutputStream() or ZstdOutputStream(level) and set the other params with the setters
public
ZstdOutputStream(OutputStream
the stream to wrap
outStream
,
int
the compression level
level
)

create a new compressing OutputStream

public
ZstdOutputStream(OutputStream
the stream to wrap
outStream
)

create a new compressing OutputStream

public
ZstdOutputStream(OutputStream
the stream to wrap
outStream
,
BufferPool
the pool to fetch and return buffers
bufferPool
,
int level)

create a new compressing OutputStream

public
ZstdOutputStream(OutputStream
the stream to wrap
outStream
,
BufferPool
the pool to fetch and return buffers
bufferPool
)

create a new compressing OutputStream

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with the stream.
protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
public void
flush()

Overrides java.io.FilterOutputStream.flush.

Implements java.io.Flushable.flush.

Flushes the output
public static long
public ZstdOutputStream
setChainLog(int chainLog)

Advanced Compression Option: Set the maximum number of bits for the secondary search structure.

public ZstdOutputStream
setChecksum(boolean useChecksums)

Enable checksums for the compressed stream.

public ZstdOutputStream
setCloseFrameOnFlush(boolean closeOnFlush)

Enable closing the frame on flush.

public ZstdOutputStream
setDict(byte[] dict)

public ZstdOutputStream
public void
setFinalize(boolean
default `true` - finalizers are enabled
finalize
)

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.
public ZstdOutputStream
setHashLog(int hashLog)

Advanced Compression Option: Set the maximum number of bits for a hash table.

public ZstdOutputStream
setJobSize(int jobSize)

Advanced Compression Option: Set the size of each compression job.

public ZstdOutputStream
setLevel(int level)

Set the compression level.

public ZstdOutputStream
setLong(int windowLog)

Set the Long Distance Matching.

public ZstdOutputStream
setMinMatch(int minMatch)

Advanced Compression Option: Set the minimum match length.

public ZstdOutputStream
setOverlapLog(int overlapLog)

Advanced Compression Option: Set the amount of data reloaded from the previous job.

public ZstdOutputStream
setSearchLog(int searchLog)

Advanced Compression Option: Set the maximum number of searches in a hash chain or a binary tree using logarithmic scale.

public ZstdOutputStream
setStrategy(int strategy)

Advanced Compression Option: Set the strategy used by a match finder.

public ZstdOutputStream
setTargetLength(int targetLength)

Advanced Compression Option: Set the target match length.

public ZstdOutputStream
setWindowLog(int windowLog)

Advanced Compression Option: Set the maximum number of bits for a match distance.

public ZstdOutputStream
setWorkers(int n)

Enable use of worker threads for parallel compression.

public void
write(byte[]
the data.
src
,
int
the start offset in the data.
offset
,
int
the number of bytes to write.
len
)

Overrides java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.
public void
write(int
the byte.
i
)

Overrides java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.
Inherited from java.io.FilterOutputStream:
write

Field Detail

innerback to summary
private ZstdOutputStreamNoFinalizer inner

Constructor Detail

ZstdOutputStreamback to summary
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

Annotations
@Deprecated
ZstdOutputStreamback to summary
public ZstdOutputStream(OutputStream outStream, int level, boolean closeFrameOnFlush) throws IOException

Deprecated

Use ZstdOutputStream() or ZstdOutputStream(level) and set the other params with the setters

Annotations
@Deprecated
ZstdOutputStreamback to summary
public ZstdOutputStream(OutputStream outStream, int level) throws IOException

create a new compressing OutputStream

Parameters
outStream:OutputStream

the stream to wrap

level:int

the compression level

ZstdOutputStreamback to summary
public ZstdOutputStream(OutputStream outStream) throws IOException

create a new compressing OutputStream

Parameters
outStream:OutputStream

the stream to wrap

ZstdOutputStreamback to summary
public ZstdOutputStream(OutputStream outStream, BufferPool bufferPool, int level) throws IOException

create a new compressing OutputStream

Parameters
outStream:OutputStream

the stream to wrap

bufferPool:BufferPool

the pool to fetch and return buffers

ZstdOutputStreamback to summary
public ZstdOutputStream(OutputStream outStream, BufferPool bufferPool) throws IOException

create a new compressing OutputStream

Parameters
outStream:OutputStream

the stream to wrap

bufferPool:BufferPool

the pool to fetch and return buffers

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.FilterOutputStream.close.

Closes this output stream and releases any system resources associated with the stream.

Exceptions
IOException:
if an I/O error occurs.
finalizeback to summary
protected void finalize() throws Throwable

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Annotations
@Override
Exceptions
Throwable:
the Exception raised by this method
flushback to summary
public void flush() throws IOException

Overrides java.io.FilterOutputStream.flush.

Implements java.io.Flushable.flush.

Flushes the output

Exceptions
IOException:

Doc from java.io.FilterOutputStream.flush.

if an I/O error occurs.

recommendedCOutSizeback to summary
public static long recommendedCOutSize()
setChainLogback to summary
public ZstdOutputStream setChainLog(int chainLog) throws IOException

Advanced Compression Option: Set the maximum number of bits for the secondary search structure. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.

setChecksumback to summary
public ZstdOutputStream setChecksum(boolean useChecksums) throws IOException

Enable checksums for the compressed stream. Default: false

setCloseFrameOnFlushback to summary
public ZstdOutputStream setCloseFrameOnFlush(boolean closeOnFlush)

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.

setDictback to summary
public ZstdOutputStream setDict(byte[] dict) throws IOException
setDictback to summary
public ZstdOutputStream setDict(ZstdDictCompress dict) throws IOException
setFinalizeback to summary
public void setFinalize(boolean finalize)

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:boolean

default `true` - finalizers are enabled

Annotations
@Deprecated
setHashLogback to summary
public ZstdOutputStream setHashLog(int hashLog) throws IOException

Advanced Compression Option: Set the maximum number of bits for a hash table. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.

setJobSizeback to summary
public ZstdOutputStream setJobSize(int jobSize) throws IOException

Advanced Compression Option: Set the size of each compression job. Only applies when multi threaded compression is enabled. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.

setLevelback to summary
public ZstdOutputStream setLevel(int level) throws IOException

Set the compression level. Default: Zstd#defaultCompressionLevel()

setLongback to summary
public ZstdOutputStream setLong(int windowLog) throws IOException

Set the Long Distance Matching. Values for windowLog outside the range 10-27 will disable and reset LDM

setMinMatchback to summary
public ZstdOutputStream setMinMatch(int minMatch) throws IOException

Advanced Compression Option: Set the minimum match length. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.

setOverlapLogback to summary
public ZstdOutputStream setOverlapLog(int overlapLog) throws IOException

Advanced Compression Option: Set the amount of data reloaded from the previous job. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.

setSearchLogback to summary
public ZstdOutputStream setSearchLog(int searchLog) throws IOException

Advanced Compression Option: Set the maximum number of searches in a hash chain or a binary tree using logarithmic scale. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.

setStrategyback to summary
public ZstdOutputStream setStrategy(int strategy) throws IOException

Advanced Compression Option: Set the strategy used by a match finder. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.

setTargetLengthback to summary
public ZstdOutputStream setTargetLength(int targetLength) throws IOException

Advanced Compression Option: Set the target match length. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.

setWindowLogback to summary
public ZstdOutputStream setWindowLog(int windowLog) throws IOException

Advanced Compression Option: Set the maximum number of bits for a match distance. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.

setWorkersback to summary
public ZstdOutputStream setWorkers(int n) throws IOException

Enable use of worker threads for parallel compression. Default: no worker threads.

writeback to summary
public void write(byte[] src, int offset, int len) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Parameters
src:byte[]

the data.

offset:int

the start offset in the data.

len:int

the number of bytes to write.

Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(int i) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.

The write method of FilterOutputStream calls the write method of its underlying output stream, that is, it performs out.write(b).

Implements the abstract write method of OutputStream.

Parameters
i:int

the byte.

Exceptions
IOException:
if an I/O error occurs.