Package org.apache.lucene.util.compress
Class LZ4
- java.lang.Object
-
- org.apache.lucene.util.compress.LZ4
-
public final class LZ4 extends java.lang.ObjectLZ4 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLZ4.FastCompressionHashTableSimple lossyLZ4.HashTablethat only stores the last ocurrence for each hash on2^14bytes of memory.(package private) static classLZ4.HashTableA record of previous occurrences of sequences of 4 bytes.static classLZ4.HighCompressionHashTableA higher-precisionLZ4.HashTable.
-
Field Summary
Fields Modifier and Type Field Description (package private) static intHASH_LOG_HC(package private) static intHASH_TABLE_SIZE_HC(package private) static intLAST_LITERALS(package private) static intMAX_DISTANCE(package private) static intMEMORY_USAGE(package private) static intMIN_MATCH(package private) static intOPTIMAL_ML
-
Constructor Summary
Constructors Modifier Constructor Description privateLZ4()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static intcommonBytes(byte[] b, int o1, int o2, int limit)static voidcompress(byte[] bytes, int off, int len, DataOutput out, LZ4.HashTable ht)Compressbytes[off:off+len]intooutusing at most 16KB of memory.static intdecompress(DataInput compressed, int decompressedLen, byte[] dest)Decompress at leastdecompressedLenbytes intodest[dOff:].private static voidencodeLastLiterals(byte[] bytes, int anchor, int literalLen, DataOutput out)private static voidencodeLen(int l, DataOutput out)private static voidencodeLiterals(byte[] bytes, int token, int anchor, int literalLen, DataOutput out)private static voidencodeSequence(byte[] bytes, int anchor, int matchRef, int matchOff, int matchLen, DataOutput out)private static inthash(int i, int hashBits)private static inthashHC(int i)private static intreadInt(byte[] buf, int i)
-
-
-
Field Detail
-
MEMORY_USAGE
static final int MEMORY_USAGE
- See Also:
- Constant Field Values
-
MIN_MATCH
static final int MIN_MATCH
- See Also:
- Constant Field Values
-
MAX_DISTANCE
static final int MAX_DISTANCE
- See Also:
- Constant Field Values
-
LAST_LITERALS
static final int LAST_LITERALS
- See Also:
- Constant Field Values
-
HASH_LOG_HC
static final int HASH_LOG_HC
- See Also:
- Constant Field Values
-
HASH_TABLE_SIZE_HC
static final int HASH_TABLE_SIZE_HC
- See Also:
- Constant Field Values
-
OPTIMAL_ML
static final int OPTIMAL_ML
- See Also:
- Constant Field Values
-
-
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) throws java.io.IOException
Decompress at leastdecompressedLenbytes intodest[dOff:]. Please note thatdestmust be large enough to be able to hold all decompressed data (meaning that you need to know the total decompressed length).- 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.IOExceptionCompressbytes[off:off+len]intooutusing at most 16KB of memory.htshouldn't be shared across threads but can safely be reused.- Throws:
java.io.IOException
-
-