Class LZ4


  • public final class LZ4
    extends java.lang.Object
    LZ4 compression and decompression routines. https://github.com/lz4/lz4/tree/dev/lib http://fastcompression.blogspot.fr/p/lz4.html The high-compression option is a simpler version of the one of the original algorithm, and only retains a better hash table that remembers about more occurrences of a previous 4-bytes sequence, and removes all the logic about handling of the case when overlapping matches are found.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private LZ4()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static int commonBytes​(byte[] b, int o1, int o2, int limit)  
      static void compress​(byte[] bytes, int off, int len, DataOutput out, LZ4.HashTable ht)
      Compress bytes[off:off+len] into out using at most 16kB of memory.
      static void compressWithDictionary​(byte[] bytes, int dictOff, int dictLen, int len, DataOutput out, LZ4.HashTable ht)
      Compress bytes[dictOff+dictLen:dictOff+dictLen+len] into out using at most 16kB of memory.
      static int decompress​(DataInput compressed, int decompressedLen, byte[] dest, int dOff)
      Decompress at least decompressedLen bytes into dest[dOff:].
      private static void encodeLastLiterals​(byte[] bytes, int anchor, int literalLen, DataOutput out)  
      private static void encodeLen​(int l, DataOutput out)  
      private static void encodeLiterals​(byte[] bytes, int token, int anchor, int literalLen, DataOutput out)  
      private static void encodeSequence​(byte[] bytes, int anchor, int matchRef, int matchOff, int matchLen, DataOutput out)  
      private static int hash​(int i, int hashBits)  
      private static int hashHC​(int i)  
      private static int readInt​(byte[] buf, int i)  
      • Methods inherited from class java.lang.Object

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

      • LZ4

        private LZ4()
    • Method Detail

      • hash

        private static int hash​(int i,
                                int hashBits)
      • hashHC

        private static int hashHC​(int i)
      • readInt

        private static int readInt​(byte[] buf,
                                   int i)
      • commonBytes

        private static int commonBytes​(byte[] b,
                                       int o1,
                                       int o2,
                                       int limit)
      • decompress

        public static int decompress​(DataInput compressed,
                                     int decompressedLen,
                                     byte[] dest,
                                     int dOff)
                              throws java.io.IOException
        Decompress at least decompressedLen bytes into dest[dOff:]. Please note that dest must be large enough to be able to hold all decompressed data (meaning that you need to know the total decompressed length). If the given bytes were compressed using a preset dictionary then the same dictionary must be provided in dest[dOff-dictLen:dOff].
        Throws:
        java.io.IOException
      • encodeLen

        private static void encodeLen​(int l,
                                      DataOutput out)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • encodeLiterals

        private static void encodeLiterals​(byte[] bytes,
                                           int token,
                                           int anchor,
                                           int literalLen,
                                           DataOutput out)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • encodeLastLiterals

        private static void encodeLastLiterals​(byte[] bytes,
                                               int anchor,
                                               int literalLen,
                                               DataOutput out)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • encodeSequence

        private static void encodeSequence​(byte[] bytes,
                                           int anchor,
                                           int matchRef,
                                           int matchOff,
                                           int matchLen,
                                           DataOutput out)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • compress

        public static void compress​(byte[] bytes,
                                    int off,
                                    int len,
                                    DataOutput out,
                                    LZ4.HashTable ht)
                             throws java.io.IOException
        Compress bytes[off:off+len] into out using at most 16kB of memory. ht shouldn't be shared across threads but can safely be reused.
        Throws:
        java.io.IOException
      • compressWithDictionary

        public static void compressWithDictionary​(byte[] bytes,
                                                  int dictOff,
                                                  int dictLen,
                                                  int len,
                                                  DataOutput out,
                                                  LZ4.HashTable ht)
                                           throws java.io.IOException
        Compress bytes[dictOff+dictLen:dictOff+dictLen+len] into out using at most 16kB of memory. bytes[dictOff:dictOff+dictLen] will be used as a dictionary. dictLen must not be greater than 64kB, the maximum window size. ht shouldn't be shared across threads but can safely be reused.
        Throws:
        java.io.IOException