Package com.github.luben.zstd
Class ZstdInputStreamNoFinalizer
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- com.github.luben.zstd.ZstdInputStreamNoFinalizer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class ZstdInputStreamNoFinalizer extends java.io.FilterInputStream
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
Fields Modifier and Type Field Description private BufferPool
bufferPool
private long
dstPos
private boolean
frameFinished
private boolean
isClosed
private boolean
isContinuous
private boolean
needRead
private byte[]
src
private static int
srcBuffSize
private java.nio.ByteBuffer
srcByteBuffer
private long
srcPos
private long
srcSize
private long
stream
-
Constructor Summary
Constructors Constructor Description ZstdInputStreamNoFinalizer(java.io.InputStream inStream)
create a new decompressing InputStreamZstdInputStreamNoFinalizer(java.io.InputStream inStream, BufferPool bufferPool)
create a new decompressing InputStream
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
private static long
createDStream()
private int
decompressStream(long stream, byte[] dst, int dst_size, byte[] src, int src_size)
private static int
freeDStream(long stream)
boolean
getContinuous()
private int
initDStream(long stream)
boolean
markSupported()
int
read()
int
read(byte[] dst, int offset, int len)
(package private) int
readInternal(byte[] dst, int offset, int len)
static long
recommendedDInSize()
static long
recommendedDOutSize()
ZstdInputStreamNoFinalizer
setContinuous(boolean b)
Don't break on unfinished frames Use case: decompressing files that are not yet finished writing and compressingZstdInputStreamNoFinalizer
setDict(byte[] dict)
ZstdInputStreamNoFinalizer
setDict(ZstdDictDecompress dict)
ZstdInputStreamNoFinalizer
setLongMax(int windowLogMax)
long
skip(long numBytes)
-
-
-
Field Detail
-
stream
private final long stream
-
dstPos
private long dstPos
-
srcPos
private long srcPos
-
srcSize
private long srcSize
-
needRead
private boolean needRead
-
bufferPool
private final BufferPool bufferPool
-
srcByteBuffer
private final java.nio.ByteBuffer srcByteBuffer
-
src
private final byte[] src
-
srcBuffSize
private static final int srcBuffSize
-
isContinuous
private boolean isContinuous
-
frameFinished
private boolean frameFinished
-
isClosed
private boolean isClosed
-
-
Constructor Detail
-
ZstdInputStreamNoFinalizer
public ZstdInputStreamNoFinalizer(java.io.InputStream inStream) throws java.io.IOException
create a new decompressing InputStream- Parameters:
inStream
- the stream to wrap- Throws:
java.io.IOException
-
ZstdInputStreamNoFinalizer
public ZstdInputStreamNoFinalizer(java.io.InputStream inStream, BufferPool bufferPool) throws java.io.IOException
create a new decompressing InputStream- Parameters:
inStream
- the stream to wrapbufferPool
- the pool to fetch and return buffers- Throws:
java.io.IOException
-
-
Method Detail
-
recommendedDInSize
public static long recommendedDInSize()
-
recommendedDOutSize
public static long recommendedDOutSize()
-
createDStream
private static long createDStream()
-
freeDStream
private static int freeDStream(long stream)
-
initDStream
private int initDStream(long stream)
-
decompressStream
private int decompressStream(long stream, byte[] dst, int dst_size, byte[] src, int src_size)
-
setContinuous
public ZstdInputStreamNoFinalizer setContinuous(boolean b)
Don't break on unfinished frames Use case: decompressing files that are not yet finished writing and compressing
-
getContinuous
public boolean getContinuous()
-
setDict
public ZstdInputStreamNoFinalizer setDict(byte[] dict) throws java.io.IOException
- Throws:
java.io.IOException
-
setDict
public ZstdInputStreamNoFinalizer setDict(ZstdDictDecompress dict) throws java.io.IOException
- Throws:
java.io.IOException
-
setLongMax
public ZstdInputStreamNoFinalizer setLongMax(int windowLogMax) throws java.io.IOException
- Throws:
java.io.IOException
-
read
public int read(byte[] dst, int offset, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
readInternal
int readInternal(byte[] dst, int offset, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException
- Overrides:
available
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.FilterInputStream
-
skip
public long skip(long numBytes) throws java.io.IOException
- Overrides:
skip
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
-