Class BaseZstdBufferDecompressingStreamNoFinalizer

    • Field Detail

      • stream

        protected long stream
      • source

        protected java.nio.ByteBuffer source
      • closed

        protected boolean closed
    • 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
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.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 the source buffer, using refill(ByteBuffer).

        To read the full stream of decompressed data, this method should be called in a loop while hasRemaining() is true.

        The target buffer will be written starting from Buffer.position(). The Buffer.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.