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.FilterInputStreamInputStream 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.
-
-
Constructor Summary
Constructors Constructor Description ZstdInputStreamNoFinalizer(@NotNull java.io.InputStream inStream)create a new decompressing InputStreamZstdInputStreamNoFinalizer(@NotNull java.io.InputStream inStream, @NotNull BufferPool bufferPool)create a new decompressing InputStream
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()booleangetContinuous()booleanmarkSupported()intread()intread(byte @NotNull [] dst, int offset, int len)static longrecommendedDInSize()static longrecommendedDOutSize()java.io.InputStreamresetSession(@NotNull java.io.InputStream newInput)Reset the decompression stream to read from a newInputStream.@NotNull ZstdInputStreamNoFinalizersetContinuous(boolean b)Don't break on unfinished frames Use case: decompressing files that are not yet finished writing and compressing@NotNull ZstdInputStreamNoFinalizersetDict(byte @NotNull [] dict)@NotNull ZstdInputStreamNoFinalizersetDict(@NotNull ZstdDictDecompress dict)@NotNull ZstdInputStreamNoFinalizersetLongMax(int windowLogMax)@NotNull ZstdInputStreamNoFinalizersetRefMultipleDDicts(boolean useMultiple)longskip(long numBytes)
-
-
-
Constructor Detail
-
ZstdInputStreamNoFinalizer
public ZstdInputStreamNoFinalizer(@NotNull @NotNull java.io.InputStream inStream) throws java.io.IOExceptioncreate a new decompressing InputStream- Parameters:
inStream- the stream to wrap- Throws:
java.io.IOException
-
ZstdInputStreamNoFinalizer
public ZstdInputStreamNoFinalizer(@NotNull @NotNull java.io.InputStream inStream, @NotNull @NotNull BufferPool bufferPool) throws java.io.IOExceptioncreate 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()
-
setContinuous
@NotNull public @NotNull 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
@NotNull public @NotNull ZstdInputStreamNoFinalizer setDict(byte @NotNull [] dict) throws java.io.IOException
- Throws:
java.io.IOException
-
setDict
@NotNull public @NotNull ZstdInputStreamNoFinalizer setDict(@NotNull @NotNull ZstdDictDecompress dict) throws java.io.IOException
- Throws:
java.io.IOException
-
setLongMax
@NotNull public @NotNull ZstdInputStreamNoFinalizer setLongMax(int windowLogMax) throws java.io.IOException
- Throws:
java.io.IOException
-
setRefMultipleDDicts
@NotNull public @NotNull ZstdInputStreamNoFinalizer setRefMultipleDDicts(boolean useMultiple) throws java.io.IOException
- Throws:
java.io.IOException
-
read
public int read(byte @NotNull [] dst, int offset, int len) throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.FilterInputStream- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.FilterInputStream
-
skip
public long skip(long numBytes) throws java.io.IOException- Overrides:
skipin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
resetSession
public java.io.InputStream resetSession(@NotNull @NotNull java.io.InputStream newInput) throws java.io.IOExceptionReset the decompression stream to read from a newInputStream. This reuses the existing nativeZSTD_DStreamcontext, including its internal window buffer and any previously loaded dictionary. The native context is reset viaZSTD_DCtx_resetwithZSTD_reset_session_only, which resets the session state without freeing or reallocating the window buffer and without clearing loaded dictionaries or parameters. If the next frame's window size fits within the existing buffer, no native memory allocation occurs at all. Previously configured settings such assetContinuous(boolean)and loaded dictionaries are preserved across the reset. The previousInputStreamis not closed; the caller is responsible for its lifecycle. This is intended for pooling: instead of creating a newZstdInputStreamNoFinalizer(which callsZSTD_createDStream+malloc) for each compressed stream and then closing it (which callsZSTD_freeDStream+free), callers can keep a single instance and callreset()with each new input stream.- Parameters:
newInput- the new compressed input stream to decompress- Returns:
- the old input stream
- Throws:
java.io.IOException- if the stream has been closed or the native reset fails
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterInputStream- Throws:
java.io.IOException
-
-