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

public Class ZstdInputStream

extends FilterInputStream
Class Inheritance
Imports
java.io.InputStream, .FilterInputStream, .IOException

InputStream filter that decompresses the data provided by the underlying InputStream using Zstd compression. It does not support mark/reset methods

Field Summary

Modifier and TypeField and Description
private ZstdInputStreamNoFinalizer
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
public
ZstdInputStream(InputStream
the stream to wrap
inStream
)

create a new decompressing InputStream

public
ZstdInputStream(InputStream
the stream to wrap
inStream
,
BufferPool
the pool to fetch and return buffers
bufferPool
)

create a new decompressing InputStream

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.FilterInputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
public void
close()

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Closes this input 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 boolean
public boolean
markSupported()

Overrides java.io.FilterInputStream.markSupported.

Tests if this input stream supports the mark and reset methods.
public int
read(byte[]
the buffer into which the data is read.
dst
,
int
the start offset in array b at which the data is written.
offset
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.
public int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.
public static long
public static long
public ZstdInputStream
setContinuous(boolean b)

Don't break on unfinished frames Use case: decompressing files that are not yet finished writing and compressing

public ZstdInputStream
setDict(byte[] dict)

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

Deprecated If you don't rely on finalizers, use `ZstdInputStreamNoFinalizer` instead, instances of `ZstdInputStream` will always try to close/release in the finalizer.
Enable or disable class finalizers
public ZstdInputStream
setLongMax(int windowLogMax)

public ZstdInputStream
setRefMultipleDDicts(boolean
Enables references table for DDict, so the DDict used for decompression will be determined per the dictId in the frame, default: false
useMultiple
)

Enable or disable support for multiple dictionary references

public long
skip(long
the number of bytes to be skipped.
numBytes
)

Overrides java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream.
Inherited from java.io.FilterInputStream:
markreadreset

Field Detail

innerback to summary
private ZstdInputStreamNoFinalizer inner

Constructor Detail

ZstdInputStreamback to summary
public ZstdInputStream(InputStream inStream) throws IOException

create a new decompressing InputStream

Parameters
inStream:InputStream

the stream to wrap

ZstdInputStreamback to summary
public ZstdInputStream(InputStream inStream, BufferPool bufferPool) throws IOException

create a new decompressing InputStream

Parameters
inStream:InputStream

the stream to wrap

bufferPool:BufferPool

the pool to fetch and return buffers

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.FilterInputStream.available.

Doc from java.io.FilterInputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Returns:int

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking.

Exceptions
IOException:
if an I/O error occurs.
closeback to summary
public void close() throws IOException

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.FilterInputStream.close.

Closes this input 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
getContinuousback to summary
public boolean getContinuous()
markSupportedback to summary
public boolean markSupported()

Overrides java.io.FilterInputStream.markSupported.

Doc from java.io.FilterInputStream.markSupported.

Tests if this input stream supports the mark and reset methods.

Returns:boolean

true if this stream type supports the mark and reset method; false otherwise.

readback to summary
public int read(byte[] dst, int offset, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Parameters
dst:byte[]

the buffer into which the data is read.

offset:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Exceptions
IOException:
if an I/O error occurs.
recommendedDInSizeback to summary
public static long recommendedDInSize()
recommendedDOutSizeback to summary
public static long recommendedDOutSize()
setContinuousback to summary
public ZstdInputStream setContinuous(boolean b)

Don't break on unfinished frames Use case: decompressing files that are not yet finished writing and compressing

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

Deprecated

If you don't rely on finalizers, use `ZstdInputStreamNoFinalizer` instead, instances of `ZstdInputStream` will always try to close/release in the finalizer.

Enable or disable class finalizers

Parameters
finalize:boolean

default `true` - finalizers are enabled

Annotations
@Deprecated
setLongMaxback to summary
public ZstdInputStream setLongMax(int windowLogMax) throws IOException
setRefMultipleDDictsback to summary
public ZstdInputStream setRefMultipleDDicts(boolean useMultiple) throws IOException

Enable or disable support for multiple dictionary references

Parameters
useMultiple:boolean

Enables references table for DDict, so the DDict used for decompression will be determined per the dictId in the frame, default: false

skipback to summary
public long skip(long numBytes) throws IOException

Overrides java.io.FilterInputStream.skip.

Doc from java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.

Parameters
numBytes:long

the number of bytes to be skipped.

Returns:long

the actual number of bytes skipped.

Exceptions
IOException:
if in.skip(n) throws an IOException.