Class BaseZstdBufferDecompressingStreamNoFinalizer
java.lang.Object
com.github.luben.zstd.BaseZstdBufferDecompressingStreamNoFinalizer
- All Implemented Interfaces:
Closeable, AutoCloseable
- Direct Known Subclasses:
ZstdBufferDecompressingStreamNoFinalizer, ZstdDirectBufferDecompressingStreamNoFinalizer
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanabstract intread(@NotNull ByteBuffer target) Reads the content of the de-compressed stream into the target buffer.protected @NotNull ByteBufferrefill(@NotNull ByteBuffer toRefill) Override this method in case the byte buffer passed to the constructor might not contain the full compressed streamsetDict(byte @NotNull [] dict) setDict(@NotNull ZstdDictDecompress dict) setLongMax(int windowLogMax) Set the value of zstd parameterZSTD_d_windowLogMax.
-
Field Details
-
stream
protected long stream -
source
-
closed
protected boolean closed
-
-
Method Details
-
refill
Override this method in case the byte buffer passed to the constructor might not contain the full compressed stream- Parameters:
toRefill- current buffer- Returns:
- either the current buffer (but refilled and flipped if there was new content) or a new buffer.
-
hasRemaining
public boolean hasRemaining()- Returns:
- false if all data is processed and no more data is available from the
source
-
setDict
@NotNull public @NotNull BaseZstdBufferDecompressingStreamNoFinalizer setDict(byte @NotNull [] dict) throws IOException - Throws:
IOException
-
setDict
@NotNull public @NotNull BaseZstdBufferDecompressingStreamNoFinalizer setDict(@NotNull @NotNull ZstdDictDecompress dict) throws IOException - Throws:
IOException
-
setLongMax
@NotNull public @NotNull BaseZstdBufferDecompressingStreamNoFinalizer setLongMax(int windowLogMax) throws IOException Set the value of zstd parameterZSTD_d_windowLogMax.- Parameters:
windowLogMax- window size in bytes- Returns:
- this instance of
BaseZstdBufferDecompressingStreamNoFinalizer - Throws:
ZstdIOException- if there is an error while setting the configuration natively.IOException- See Also:
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
read
Reads the content of the de-compressed stream into the target buffer.This method will block until the chunk of compressed data stored in
sourcehas been decompressed and written into the target buffer. After each execution, this method will refill thesourcebuffer, usingrefill(ByteBuffer).To read the full stream of decompressed data, this method should be called in a loop while
hasRemaining()istrue.The target buffer will be written starting from
Buffer.position(). TheBuffer.position()of source and the target buffers will be modified to represent the data read and written respectively.- Parameters:
target- buffer to store the read bytes from uncompressed stream.- Returns:
- the number of bytes read into the target buffer.
- Throws:
ZstdIOException- if an error occurs while reading.IllegalArgumentException- if provided source or target buffers are incorrectly configured.IOException- if the stream is closed before reading.
-