LZ4

object 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.

Types

Link copied to clipboard

Simple lossy HashTable that only stores the last occurrence for each hash on 2^14 bytes of memory.

Link copied to clipboard
abstract class HashTable

A record of previous occurrences of sequences of 4 bytes.

Link copied to clipboard

A higher-precision HashTable. It stores up to 256 occurrences of 4-bytes sequences in the last 2^16 bytes, which makes it much more likely to find matches than [ ].

Properties

Link copied to clipboard
const val HASH_LOG_HC: Int = 15
Link copied to clipboard
Link copied to clipboard
const val LAST_LITERALS: Int = 5
Link copied to clipboard
const val MAX_DISTANCE: 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.

Link copied to clipboard
const val MEMORY_USAGE: Int = 14
Link copied to clipboard
const val MIN_MATCH: Int = 4

Functions

Link copied to clipboard
fun compress(bytes: ByteArray, off: Int, len: Int, out: DataOutput, ht: LZ4.HashTable)

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.

Link copied to clipboard
fun compressWithDictionary(bytes: ByteArray, dictOff: Int, dictLen: Int, len: Int, out: DataOutput, ht: LZ4.HashTable)

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.

Link copied to clipboard
fun decompress(compressed: DataInput, decompressedLen: Int, dest: ByteArray, dOff: Int): Int

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].