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

public Class ZstdInputStreamNoFinalizer

extends FilterInputStream
Class Inheritance
Imports
java.io.InputStream, .FilterInputStream, .IOException, java.lang.IndexOutOfBoundsException, java.nio.ByteBuffer, com.github.luben.zstd.util.Native

InputStream filter that decompresses the data provided by the underlying InputStream using Zstd compression. It does not support mark/reset methods. It also does not have finalizer, so if you rely on finalizers to clean the native memory and release buffers use `ZstdInputStream` instead.

Field Summary

Modifier and TypeField and Description
private final BufferPool
private long
private boolean
private boolean
private boolean
private boolean
private final byte[]
private static final int
private final ByteBuffer
private long
private long
private final long
Inherited from java.io.FilterInputStream:
in

Constructor Summary

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

create a new decompressing InputStream

public
ZstdInputStreamNoFinalizer(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 synchronized 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 synchronized 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.
private static native long
private native int
decompressStream(long stream, byte[] dst, int dst_size, byte[] src, int src_size)

private static native int
freeDStream(long stream)

public synchronized boolean
private native int
initDStream(long stream)

public boolean
markSupported()

Overrides java.io.FilterInputStream.markSupported.

Tests if this input stream supports the mark and reset methods.
public synchronized 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 synchronized int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.
pack-priv int
readInternal(byte[] dst, int offset, int len)

public static native long
public static native long
public synchronized ZstdInputStreamNoFinalizer
setContinuous(boolean b)

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

public synchronized ZstdInputStreamNoFinalizer
setDict(byte[] dict)

public synchronized ZstdInputStreamNoFinalizer
public synchronized ZstdInputStreamNoFinalizer
setLongMax(int windowLogMax)

public synchronized ZstdInputStreamNoFinalizer
setRefMultipleDDicts(boolean useMultiple)

public synchronized 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

bufferPoolback to summary
private final BufferPool bufferPool
dstPosback to summary
private long dstPos
frameFinishedback to summary
private boolean frameFinished
isClosedback to summary
private boolean isClosed
isContinuousback to summary
private boolean isContinuous
needReadback to summary
private boolean needRead
srcback to summary
private final byte[] src
srcBuffSizeback to summary
private static final int srcBuffSize
srcByteBufferback to summary
private final ByteBuffer srcByteBuffer
srcPosback to summary
private long srcPos
srcSizeback to summary
private long srcSize
streamback to summary
private final long stream

Constructor Detail

ZstdInputStreamNoFinalizerback to summary
public ZstdInputStreamNoFinalizer(InputStream inStream) throws IOException

create a new decompressing InputStream

Parameters
inStream:InputStream

the stream to wrap

ZstdInputStreamNoFinalizerback to summary
public ZstdInputStreamNoFinalizer(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 synchronized 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 synchronized 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.
createDStreamback to summary
private static native long createDStream()
decompressStreamback to summary
private native int decompressStream(long stream, byte[] dst, int dst_size, byte[] src, int src_size)
freeDStreamback to summary
private static native int freeDStream(long stream)
getContinuousback to summary
public synchronized boolean getContinuous()
initDStreamback to summary
private native int initDStream(long stream)
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 synchronized 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 synchronized 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.
readInternalback to summary
pack-priv int readInternal(byte[] dst, int offset, int len) throws IOException
recommendedDInSizeback to summary
public static native long recommendedDInSize()
recommendedDOutSizeback to summary
public static native long recommendedDOutSize()
setContinuousback to summary
public synchronized ZstdInputStreamNoFinalizer 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 synchronized ZstdInputStreamNoFinalizer setDict(byte[] dict) throws IOException
setDictback to summary
public synchronized ZstdInputStreamNoFinalizer setDict(ZstdDictDecompress dict) throws IOException
setLongMaxback to summary
public synchronized ZstdInputStreamNoFinalizer setLongMax(int windowLogMax) throws IOException
setRefMultipleDDictsback to summary
public synchronized ZstdInputStreamNoFinalizer setRefMultipleDDicts(boolean useMultiple) throws IOException
skipback to summary
public synchronized 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.