Package org.apache.lucene.util.compress
Class LZ4
java.lang.Object
org.apache.lucene.util.compress.LZ4
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Simple lossyLZ4.HashTable
that only stores the last ocurrence for each hash on2^14
bytes of memory.static final class
A higher-precisionLZ4.HashTable
. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Window size: this is the maximum supported distance between two strings so that LZ4 can replace the second one by a reference to the first one. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
compress
(byte[] bytes, int off, int len, DataOutput out, org.apache.lucene.util.compress.LZ4.HashTable ht) Compressbytes[off:off+len]
intoout
using at most 16kB of memory.static void
compressWithDictionary
(byte[] bytes, int dictOff, int dictLen, int len, DataOutput out, org.apache.lucene.util.compress.LZ4.HashTable ht) Compressbytes[dictOff+dictLen:dictOff+dictLen+len]
intoout
using at most 16kB of memory.static int
decompress
(DataInput compressed, int decompressedLen, byte[] dest, int dOff) Decompress at leastdecompressedLen
bytes intodest[dOff:]
.
-
Field Details
-
MAX_DISTANCE
public static final int MAX_DISTANCEWindow size: this is the maximum supported distance between two strings so that LZ4 can replace the second one by a reference to the first one.- See Also:
-
-
Method Details
-
decompress
public static int decompress(DataInput compressed, int decompressedLen, byte[] dest, int dOff) throws IOException Decompress at leastdecompressedLen
bytes intodest[dOff:]
. Please note thatdest
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 indest[dOff-dictLen:dOff]
.- Throws:
IOException
-
compress
public static void compress(byte[] bytes, int off, int len, DataOutput out, org.apache.lucene.util.compress.LZ4.HashTable ht) throws IOException Compressbytes[off:off+len]
intoout
using at most 16kB of memory.ht
shouldn't be shared across threads but can safely be reused.- Throws:
IOException
-
compressWithDictionary
public static void compressWithDictionary(byte[] bytes, int dictOff, int dictLen, int len, DataOutput out, org.apache.lucene.util.compress.LZ4.HashTable ht) throws IOException Compressbytes[dictOff+dictLen:dictOff+dictLen+len]
intoout
using at most 16kB of memory.bytes[dictOff:dictOff+dictLen]
will be used as a dictionary.dictLen
must not be greater than64kB
, the maximum window size.ht
shouldn't be shared across threads but can safely be reused.- Throws:
IOException
-