Class ZstdDecompressCtx

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class ZstdDecompressCtx
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ZstdDecompressCtx()
      Create a context for faster compress operations One such context is required for each thread - put this in a ThreadLocal.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      int decompress​(byte @NotNull [] dst, byte @NotNull [] src)  
      byte @NotNull [] decompress​(byte @NotNull [] src, int originalSize)
      Decompress data
      byte @NotNull [] decompress​(byte @NotNull [] src, int srcOffset, int srcSize, int originalSize)
      Decompress data
      int decompress​(byte @NotNull [] dst, @NotNull java.nio.ByteBuffer srcBuf)  
      int decompress​(@NotNull java.nio.ByteBuffer dstBuf, byte @NotNull [] src)  
      @NotNull java.nio.ByteBuffer decompress​(@NotNull java.nio.ByteBuffer srcBuf, int originalSize)  
      int decompress​(@NotNull java.nio.ByteBuffer dstBuf, @NotNull java.nio.ByteBuffer srcBuf)
      Decompresses buffer 'srcBuff' into buffer 'dstBuff' using this ZstdDecompressCtx.
      int decompressByteArray​(byte @NotNull [] dstBuff, int dstOffset, int dstSize, byte @NotNull [] srcBuff, int srcOffset, int srcSize)
      Decompresses byte array 'srcBuff' into byte array 'dstBuff' using this ZstdDecompressCtx.
      int decompressByteArrayToDirectByteBuffer​(@NotNull java.nio.ByteBuffer dstBuff, int dstOffset, int dstSize, byte @NotNull [] srcBuff, int srcOffset, int srcSize)  
      int decompressDirectByteBuffer​(@NotNull java.nio.ByteBuffer dstBuff, int dstOffset, int dstSize, @NotNull java.nio.ByteBuffer srcBuff, int srcOffset, int srcSize)
      Decompresses buffer 'srcBuff' into buffer 'dstBuff' using this ZstdDecompressCtx.
      boolean decompressDirectByteBufferStream​(@NotNull java.nio.ByteBuffer dst, @NotNull java.nio.ByteBuffer src)
      Decompress as much of the src ByteBuffer into the dst ByteBuffer as possible.
      int decompressDirectByteBufferToByteArray​(byte @NotNull [] dstBuff, int dstOffset, int dstSize, @NotNull java.nio.ByteBuffer srcBuff, int srcOffset, int srcSize)  
      @NotNull ZstdDecompressCtx loadDict​(byte @Nullable [] dict)
      Load decompression dictionary.
      @NotNull ZstdDecompressCtx loadDict​(@Nullable ZstdDictDecompress dict)
      Load decompression dictionary
      void reset()
      Clear all state and parameters from the decompression context.
      @NotNull ZstdDecompressCtx setMagicless​(boolean magiclessFlag)
      Enable or disable magicless frames
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ZstdDecompressCtx

        public ZstdDecompressCtx()
        Create a context for faster compress operations One such context is required for each thread - put this in a ThreadLocal.
    • Method Detail

      • setMagicless

        @NotNull
        public @NotNull ZstdDecompressCtx setMagicless​(boolean magiclessFlag)
        Enable or disable magicless frames
        Parameters:
        magiclessFlag - A 32-bits checksum of content is written at end of frame, default: false
      • loadDict

        @NotNull
        public @NotNull ZstdDecompressCtx loadDict​(@Nullable
                                                   @Nullable ZstdDictDecompress dict)
        Load decompression dictionary
        Parameters:
        dict - the dictionary
      • loadDict

        @NotNull
        public @NotNull ZstdDecompressCtx loadDict​(byte @Nullable [] dict)
        Load decompression dictionary.
        Parameters:
        dict - the dictionary or `null` to remove loaded dictionary
      • reset

        public void reset()
        Clear all state and parameters from the decompression context. This leaves the object in a state identical to a newly created decompression context.
      • decompressDirectByteBufferStream

        public boolean decompressDirectByteBufferStream​(@NotNull
                                                        @NotNull java.nio.ByteBuffer dst,
                                                        @NotNull
                                                        @NotNull java.nio.ByteBuffer src)
        Decompress as much of the src ByteBuffer into the dst ByteBuffer as possible.
        Parameters:
        dst - destination of uncompressed data
        src - buffer to decompress
        Returns:
        true if all state has been flushed from internal buffers
      • decompressDirectByteBuffer

        public int decompressDirectByteBuffer​(@NotNull
                                              @NotNull java.nio.ByteBuffer dstBuff,
                                              int dstOffset,
                                              int dstSize,
                                              @NotNull
                                              @NotNull java.nio.ByteBuffer srcBuff,
                                              int srcOffset,
                                              int srcSize)
        Decompresses buffer 'srcBuff' into buffer 'dstBuff' using this ZstdDecompressCtx.

        Destination buffer should be sized to be larger of equal to the originalSize. This is a low-level function that does not take into account or affect the `limit` or `position` of source or destination buffers.

        Parameters:
        dstBuff - the destination buffer - must be direct
        dstOffset - the start offset of 'dstBuff'
        dstSize - the size of 'dstBuff'
        srcBuff - the source buffer - must be direct
        srcOffset - the start offset of 'srcBuff'
        srcSize - the size of 'srcBuff'
        Returns:
        the number of bytes decompressed into destination buffer (originalSize)
      • decompressByteArray

        public int decompressByteArray​(byte @NotNull [] dstBuff,
                                       int dstOffset,
                                       int dstSize,
                                       byte @NotNull [] srcBuff,
                                       int srcOffset,
                                       int srcSize)
        Decompresses byte array 'srcBuff' into byte array 'dstBuff' using this ZstdDecompressCtx.

        Destination buffer should be sized to be larger of equal to the originalSize.

        Parameters:
        dstBuff - the destination buffer
        dstOffset - the start offset of 'dstBuff'
        dstSize - the size of 'dstBuff'
        srcBuff - the source buffer
        srcOffset - the start offset of 'srcBuff'
        srcSize - the size of 'srcBuff'
        Returns:
        the number of bytes decompressed into destination buffer (originalSize)
      • decompressByteArrayToDirectByteBuffer

        public int decompressByteArrayToDirectByteBuffer​(@NotNull
                                                         @NotNull java.nio.ByteBuffer dstBuff,
                                                         int dstOffset,
                                                         int dstSize,
                                                         byte @NotNull [] srcBuff,
                                                         int srcOffset,
                                                         int srcSize)
      • decompressDirectByteBufferToByteArray

        public int decompressDirectByteBufferToByteArray​(byte @NotNull [] dstBuff,
                                                         int dstOffset,
                                                         int dstSize,
                                                         @NotNull
                                                         @NotNull java.nio.ByteBuffer srcBuff,
                                                         int srcOffset,
                                                         int srcSize)
      • decompress

        public int decompress​(@NotNull
                              @NotNull java.nio.ByteBuffer dstBuf,
                              @NotNull
                              @NotNull java.nio.ByteBuffer srcBuf)
                       throws ZstdException
        Decompresses buffer 'srcBuff' into buffer 'dstBuff' using this ZstdDecompressCtx.

        Destination buffer should be sized to be larger of equal to the originalSize.

        Parameters:
        dstBuf - the destination buffer - must be direct. It is assumed that the `position()` of this buffer marks the offset at which the decompressed data are to be written, and that the `limit()` of this buffer is the maximum decompressed data size to allow.

        When this method returns successfully, its `position()` will be set to its current `position()` plus the decompressed size of the data.

        srcBuf - the source buffer - must be direct. It is assumed that the `position()` of this buffer marks the beginning of the compressed data to be decompressed, and that the `limit()` of this buffer marks its end.

        When this method returns successfully, its `position()` will be set to the initial `limit()`.

        Returns:
        the size of the decompressed data.
        Throws:
        ZstdException
      • decompress

        public int decompress​(@NotNull
                              @NotNull java.nio.ByteBuffer dstBuf,
                              byte @NotNull [] src)
                       throws ZstdException
        Throws:
        ZstdException
      • decompress

        public int decompress​(byte @NotNull [] dst,
                              @NotNull
                              @NotNull java.nio.ByteBuffer srcBuf)
                       throws ZstdException
        Throws:
        ZstdException
      • decompress

        @NotNull
        public @NotNull java.nio.ByteBuffer decompress​(@NotNull
                                                       @NotNull java.nio.ByteBuffer srcBuf,
                                                       int originalSize)
                                                throws ZstdException
        Throws:
        ZstdException
      • decompress

        public int decompress​(byte @NotNull [] dst,
                              byte @NotNull [] src)
      • decompress

        public byte @NotNull [] decompress​(byte @NotNull [] src,
                                           int originalSize)
                                    throws ZstdException
        Decompress data
        Parameters:
        src - the source buffer
        originalSize - the maximum size of the uncompressed data. If originalSize is greater than the actual uncompressed size, additional memory copy going to happen. If originalSize is smaller than the uncompressed size, ZstdException will be thrown.
        Returns:
        byte array with the decompressed data
        Throws:
        ZstdException
      • decompress

        public byte @NotNull [] decompress​(byte @NotNull [] src,
                                           int srcOffset,
                                           int srcSize,
                                           int originalSize)
                                    throws ZstdException
        Decompress data
        Parameters:
        src - the source buffer
        srcOffset - the start offset of 'src'
        srcSize - the size of 'src'
        originalSize - the maximum size of the uncompressed data. If originalSize is greater than the actual uncompressed size, additional memory copy going to happen. If originalSize is smaller than the uncompressed size, ZstdException will be thrown.
        Returns:
        byte array with the decompressed data
        Throws:
        ZstdException
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable