Class LZ4DecompressorWithLength


  • public class LZ4DecompressorWithLength
    extends java.lang.Object
    Convenience class to decompress data compressed by LZ4CompressorWithLength. This decompressor is NOT compatible with any other compressors in lz4-java or any other lz4 tools. The user does not need to specify the length of the compressed data or original data because the length of the original decompressed data is included in the compressed data.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] decompress​(byte[] src)
      Convenience method, equivalent to calling decompress(src, 0).
      int decompress​(byte[] src, byte[] dest)
      Convenience method, equivalent to calling decompress(src, 0, dest, 0).
      byte[] decompress​(byte[] src, int srcOff)
      Convenience method which returns src[srcOff:] decompressed when LZ4FastDecompressor was specified to the constructor, or src[srcOff:src.length] decompressed when LZ4SafeDecompressor was specified to the constructor.
      int decompress​(byte[] src, int srcOff, byte[] dest, int destOff)
      When LZ4FastDecompressor was specified to the constructor, decompresses src[srcOff:] into dest[destOff:] and returns the number of bytes read from src, and when LZ4SafeDecompressor was specified to the constructor, decompresses src[srcOff:src.length] into dest[destOff:] and returns the number of decompressed bytes written into dest.
      byte[] decompress​(byte[] src, int srcOff, int srcLen)
      Convenience method which returns src[srcOff:] decompressed when LZ4FastDecompressor was specified to the constructor, or src[srcOff:srcOff+srcLen] decompressed when LZ4SafeDecompressor was specified to the constructor.
      int decompress​(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff)
      When LZ4FastDecompressor was specified to the constructor, decompresses src[srcOff:] into dest[destOff:] and returns the number of bytes read from src, and when LZ4SafeDecompressor was specified to the constructor, decompresses src[srcOff:srcOff+srcLen] into dest[destOff:] and returns the number of decompressed bytes written into dest.
      int decompress​(java.nio.ByteBuffer src, int srcOff, int srcLen, java.nio.ByteBuffer dest, int destOff)
      When LZ4FastDecompressor was specified to the constructor, decompresses src[srcOff:] into dest[destOff:] and returns the number of bytes read from src, and when LZ4SafeDecompressor was specified to the constructor, decompresses src[srcOff:srcOff+srcLen] into dest[destOff:] and returns the number of decompressed bytes written into dest.
      int decompress​(java.nio.ByteBuffer src, int srcOff, java.nio.ByteBuffer dest, int destOff)
      When LZ4FastDecompressor was specified to the constructor, decompresses src[srcOff:] into dest[destOff:] and returns the number of bytes read from src, and when LZ4SafeDecompressor was specified to the constructor, decompresses src[srcOff:src.remaining()] into dest[destOff:] and returns the number of decompressed bytes written into dest.
      void decompress​(java.nio.ByteBuffer src, java.nio.ByteBuffer dest)
      Decompresses src into dest.
      static int getDecompressedLength​(byte[] src)
      Returns the decompressed length of compressed data in src.
      static int getDecompressedLength​(byte[] src, int srcOff)
      Returns the decompressed length of compressed data in src[srcOff:].
      static int getDecompressedLength​(java.nio.ByteBuffer src)
      Returns the decompressed length of compressed data in src.
      static int getDecompressedLength​(java.nio.ByteBuffer src, int srcOff)
      Returns the decompressed length of compressed data in src[srcOff:].
      • Methods inherited from class java.lang.Object

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

      • getDecompressedLength

        public static int getDecompressedLength​(byte[] src)
        Returns the decompressed length of compressed data in src.
        Parameters:
        src - the compressed data
        Returns:
        the decompressed length
      • getDecompressedLength

        public static int getDecompressedLength​(byte[] src,
                                                int srcOff)
        Returns the decompressed length of compressed data in src[srcOff:].
        Parameters:
        src - the compressed data
        srcOff - the start offset in src
        Returns:
        the decompressed length
      • getDecompressedLength

        public static int getDecompressedLength​(java.nio.ByteBuffer src)
        Returns the decompressed length of compressed data in src.
        Parameters:
        src - the compressed data
        Returns:
        the decompressed length
      • getDecompressedLength

        public static int getDecompressedLength​(java.nio.ByteBuffer src,
                                                int srcOff)
        Returns the decompressed length of compressed data in src[srcOff:].
        Parameters:
        src - the compressed data
        srcOff - the start offset in src
        Returns:
        the decompressed length
      • decompress

        public int decompress​(byte[] src,
                              byte[] dest)
        Convenience method, equivalent to calling decompress(src, 0, dest, 0).
        Parameters:
        src - the compressed data
        dest - the destination buffer to store the decompressed data
        Returns:
        the number of bytes read to restore the original input
      • decompress

        public int decompress​(byte[] src,
                              int srcOff,
                              byte[] dest,
                              int destOff)
        When LZ4FastDecompressor was specified to the constructor, decompresses src[srcOff:] into dest[destOff:] and returns the number of bytes read from src, and when LZ4SafeDecompressor was specified to the constructor, decompresses src[srcOff:src.length] into dest[destOff:] and returns the number of decompressed bytes written into dest.
        Parameters:
        src - the compressed data
        srcOff - the start offset in src
        dest - the destination buffer to store the decompressed data
        destOff - the start offset in dest
        Returns:
        the number of bytes read to restore the original input (when LZ4FastDecompressor is used), or the number of decompressed bytes (when LZ4SafeDecompressor is used)
      • decompress

        public int decompress​(byte[] src,
                              int srcOff,
                              int srcLen,
                              byte[] dest,
                              int destOff)
        When LZ4FastDecompressor was specified to the constructor, decompresses src[srcOff:] into dest[destOff:] and returns the number of bytes read from src, and when LZ4SafeDecompressor was specified to the constructor, decompresses src[srcOff:srcOff+srcLen] into dest[destOff:] and returns the number of decompressed bytes written into dest.
        Parameters:
        src - the compressed data
        srcOff - the start offset in src
        srcLen - the exact size of the compressed data (ignored when LZ4FastDecompressor is used)
        dest - the destination buffer to store the decompressed data
        destOff - the start offset in dest
        Returns:
        the number of bytes read to restore the original input (when LZ4FastDecompressor is used), or the number of decompressed bytes (when LZ4SafeDecompressor is used)
      • decompress

        public byte[] decompress​(byte[] src)
        Convenience method, equivalent to calling decompress(src, 0).
        Parameters:
        src - the compressed data
        Returns:
        the decompressed data
      • decompress

        public byte[] decompress​(byte[] src,
                                 int srcOff)
        Convenience method which returns src[srcOff:] decompressed when LZ4FastDecompressor was specified to the constructor, or src[srcOff:src.length] decompressed when LZ4SafeDecompressor was specified to the constructor.

        Warning: this method has an important overhead due to the fact that it needs to allocate a buffer to decompress into.

        Parameters:
        src - the compressed data
        srcOff - the start offset in src
        Returns:
        the decompressed data
      • decompress

        public byte[] decompress​(byte[] src,
                                 int srcOff,
                                 int srcLen)
        Convenience method which returns src[srcOff:] decompressed when LZ4FastDecompressor was specified to the constructor, or src[srcOff:srcOff+srcLen] decompressed when LZ4SafeDecompressor was specified to the constructor.

        Warning: this method has an important overhead due to the fact that it needs to allocate a buffer to decompress into.

        Parameters:
        src - the compressed data
        srcOff - the start offset in src
        srcLen - the exact size of the compressed data (ignored when LZ4FastDecompressor is used)
        Returns:
        the decompressed data
      • decompress

        public void decompress​(java.nio.ByteBuffer src,
                               java.nio.ByteBuffer dest)
        Decompresses src into dest. When LZ4SafeDecompressor was specified to the constructor, src's Buffer.remaining() must be exactly the size of the compressed data. This method moves the positions of the buffers.
        Parameters:
        src - the compressed data
        dest - the destination buffer to store the decompressed data
      • decompress

        public int decompress​(java.nio.ByteBuffer src,
                              int srcOff,
                              java.nio.ByteBuffer dest,
                              int destOff)
        When LZ4FastDecompressor was specified to the constructor, decompresses src[srcOff:] into dest[destOff:] and returns the number of bytes read from src, and when LZ4SafeDecompressor was specified to the constructor, decompresses src[srcOff:src.remaining()] into dest[destOff:] and returns the number of decompressed bytes written into dest. The positions and limits of the ByteBuffers remain unchanged.
        Parameters:
        src - the compressed data
        srcOff - the start offset in src
        dest - the destination buffer to store the decompressed data
        destOff - the start offset in dest
        Returns:
        the number of bytes read to restore the original input (when LZ4FastDecompressor is used), or the number of decompressed bytes (when LZ4SafeDecompressor is used)
      • decompress

        public int decompress​(java.nio.ByteBuffer src,
                              int srcOff,
                              int srcLen,
                              java.nio.ByteBuffer dest,
                              int destOff)
        When LZ4FastDecompressor was specified to the constructor, decompresses src[srcOff:] into dest[destOff:] and returns the number of bytes read from src, and when LZ4SafeDecompressor was specified to the constructor, decompresses src[srcOff:srcOff+srcLen] into dest[destOff:] and returns the number of decompressed bytes written into dest. The positions and limits of the ByteBuffers remain unchanged.
        Parameters:
        src - the compressed data
        srcOff - the start offset in src
        srcLen - the exact size of the compressed data (ignored when LZ4FastDecompressor is used)
        dest - the destination buffer to store the decompressed data
        destOff - the start offset in dest
        Returns:
        the number of bytes read to restore the original input (when LZ4FastDecompressor is used), or the number of decompressed bytes (when LZ4SafeDecompressor is used)