Package com.github.luben.zstd
Class BaseZstdBufferDecompressingStreamNoFinalizer
- java.lang.Object
-
- com.github.luben.zstd.BaseZstdBufferDecompressingStreamNoFinalizer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
ZstdBufferDecompressingStreamNoFinalizer
,ZstdDirectBufferDecompressingStreamNoFinalizer
public abstract class BaseZstdBufferDecompressingStreamNoFinalizer extends java.lang.Object implements java.io.Closeable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
hasRemaining()
abstract int
read(java.nio.ByteBuffer target)
Reads the content of the de-compressed stream into the target buffer.protected java.nio.ByteBuffer
refill(java.nio.ByteBuffer toRefill)
Override this method in case the byte buffer passed to the constructor might not contain the full compressed streamBaseZstdBufferDecompressingStreamNoFinalizer
setDict(byte[] dict)
BaseZstdBufferDecompressingStreamNoFinalizer
setDict(ZstdDictDecompress dict)
BaseZstdBufferDecompressingStreamNoFinalizer
setLongMax(int windowLogMax)
Set the value of zstd parameterZSTD_d_windowLogMax
.
-
-
-
Method Detail
-
refill
protected java.nio.ByteBuffer refill(java.nio.ByteBuffer toRefill)
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
public BaseZstdBufferDecompressingStreamNoFinalizer setDict(byte[] dict) throws java.io.IOException
- Throws:
java.io.IOException
-
setDict
public BaseZstdBufferDecompressingStreamNoFinalizer setDict(ZstdDictDecompress dict) throws java.io.IOException
- Throws:
java.io.IOException
-
setLongMax
public BaseZstdBufferDecompressingStreamNoFinalizer setLongMax(int windowLogMax) throws java.io.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.java.io.IOException
- See Also:
- Zstd's ZSTD_d_windowLogMax parameter
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
read
public abstract int read(java.nio.ByteBuffer target) throws java.io.IOException
Reads the content of the de-compressed stream into the target buffer.This method will block until the chunk of compressed data stored in
source
has been decompressed and written into the target buffer. After each execution, this method will refill thesource
buffer, 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.java.lang.IllegalArgumentException
- if provided source or target buffers are incorrectly configured.java.io.IOException
- if the stream is closed before reading.
-
-