Buffer using the LZ4 format.
See original LZ4 Github project
and LZ4 block format
for full description.
Since the original LZ4 block format does not contains size of compressed block and size of original data
this encoder uses format like LZ4 Java library
written by Adrien Grand and approved by Yann Collet (author of original LZ4 library).
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Magic * Token * Compressed * Decompressed * Checksum * + * LZ4 compressed *
* * * length * length * * * block *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
| Modifier and Type | Class and Description |
|---|---|
| private static enum |
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private final BufferChecksum | checksum
Underlying checksum calculator in use. |
| private final int | compressionLevel
Compression level of current LZ4 encoder (depends on |
| private final LZ4Compressor | compressor
Underlying compressor in use. |
| pack-priv static final int | |
| private final int | maxEncodeSize
Maximum size for any buffer to write encoded (compressed) data into. |
| private Lz4Compressor. |
| Access | Constructor and Description |
|---|---|
| private | Lz4Compressor(LZ4Factory factory, boolean highCompressor, int blockSize, Checksum checksum, int maxEncodeSize)
|
| Modifier and Type | Method and Description |
|---|---|
| private Buffer | |
| public void | |
| public Buffer | compress(Buffer
the input, BufferAllocator Buffer that contains the data to be compressed.the allocator)BufferAllocator that is used to allocate a new buffer (if needed) to write the
compressed bytes too.Implements io. Buffer and compress into a new Buffer that will be
allocated (if needed) from the BufferAllocator.
|
| private void | compressData(Buffer in, Buffer out)
Encodes the input buffer into |
| private static int | |
| public Buffer | finish(BufferAllocator allocator)
Implements io. |
| public boolean | isClosed()
Implements io. true if the decompressor was closed, false otherwise.
|
| public boolean | isFinished()
Implements io. true if the compressor was finished or closed.
|
| public static Supplier | newFactory()
Creates the fastest LZ4 compressor factory with default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github. |
| public static Supplier | Returns: the factory.if highCompressor)true codec will use compressor which requires more memory
and is slower but compresses more efficientlyCreates a new LZ4 compressor factory with high or fast compression, default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github. |
| public static Supplier | Returns: the factory.user customizable factory, boolean LZ4Factory instance
which may be JNI bindings to the original C implementation, a pure Java implementation
or a Java implementation that uses the sun.if highCompressor, int true codec will use compressor which requires more memory
and is slower but compresses more efficientlythe maximum number of bytes to try to compress at once,
must be >= 64 and <= 32 M blockSize, Checksum the checksum)Checksum instance to use to check data for integrityCreates a new customizable LZ4 compressor factory. |
| public static Supplier | Returns: the factory.user customizable factory, boolean LZ4Factory instance
which may be JNI bindings to the original C implementation, a pure Java implementation
or a Java implementation that uses the sun.if highCompressor, int true codec will use compressor which requires more memory
and is slower but compresses more efficientlythe maximum number of bytes to try to compress at once,
must be >= 64 and <= 32 M blockSize, Checksum the checksum, int Checksum instance to use to check data for integritythe maximum size for an encode (compressed) buffer maxEncodeSize)Creates a new customizable LZ4 compressor factory. |
| blockSize | back to summary |
|---|---|
| private final int blockSize | |
| checksum | back to summary |
|---|---|
| private final BufferChecksum checksum Underlying checksum calculator in use. | |
| compressionLevel | back to summary |
|---|---|
| private final int compressionLevel Compression level of current LZ4 encoder (depends on | |
| compressor | back to summary |
|---|---|
| private final LZ4Compressor compressor Underlying compressor in use. | |
| DEFAULT_MAX_ENCODE_SIZE | back to summary |
|---|---|
| pack-priv static final int DEFAULT_MAX_ENCODE_SIZE | |
| maxEncodeSize | back to summary |
|---|---|
| private final int maxEncodeSize Maximum size for any buffer to write encoded (compressed) data into. | |
| state | back to summary |
|---|---|
| private Lz4Compressor. | |
| Lz4Compressor | back to summary |
|---|---|
| private Lz4Compressor(LZ4Factory factory, boolean highCompressor, int blockSize, Checksum checksum, int maxEncodeSize) | |
| allocateBuffer | back to summary |
|---|---|
| private Buffer allocateBuffer(BufferAllocator allocator, Buffer msg) | |
| close | back to summary |
|---|---|
| public void close() Implements io. Doc from io. #
Close the compressor. After this method was called
| |
| compress | back to summary |
|---|---|
| public Buffer compress(Buffer input, BufferAllocator allocator) throws CompressionException Implements io. Doc from io. This method will read from the input
| |
| compressData | back to summary |
|---|---|
| private void compressData(Buffer in, Buffer out) Encodes the input buffer into | |
| compressionLevel | back to summary |
|---|---|
| private static int compressionLevel(int blockSize) Calculates compression level on the basis of block size. | |
| finish | back to summary |
|---|---|
| public Buffer finish(BufferAllocator allocator) Implements io. Doc from io. By calling this method we signal that the compression stream is marked as finish. The returned | |
| isClosed | back to summary |
|---|---|
| public boolean isClosed() Implements io. Doc from io. Return
| |
| isFinished | back to summary |
|---|---|
| public boolean isFinished() Implements io. Doc from io. Returns
| |
| newFactory | back to summary |
|---|---|
| public static Supplier Creates the fastest LZ4 compressor factory with default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github. | |
| newFactory | back to summary |
|---|---|
| public static Supplier Creates a new LZ4 compressor factory with high or fast compression, default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github.
| |
| newFactory | back to summary |
|---|---|
| public static Supplier Creates a new customizable LZ4 compressor factory.
| |
| newFactory | back to summary |
|---|---|
| public static Supplier Creates a new customizable LZ4 compressor factory.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final Lz4Compressor. | |
| public static final Lz4Compressor. | |
| public static final Lz4Compressor. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Lz4Compressor. | |
| public static Lz4Compressor. |
| CLOSED | back to summary |
|---|---|
| public static final Lz4Compressor. | |
| FINISHED | back to summary |
|---|---|
| public static final Lz4Compressor. | |
| PROCESSING | back to summary |
|---|---|
| public static final Lz4Compressor. | |
| State | back to summary |
|---|---|
| private State() | |
| valueOf | back to summary |
|---|---|
| public static Lz4Compressor. | |
| values | back to summary |
|---|---|
| public static Lz4Compressor. | |