Top Description Inners Fields Constructors Methods
io.netty5.handler.codec.compression

public final Class Lz4Decompressor

extends Object
implements Decompressor
Class Inheritance
All Implemented Interfaces
io.netty5.handler.codec.compression.Decompressor, java.lang.AutoCloseable
Imports
io.netty5.buffer.Buffer, .BufferAllocator, net.jpountz.lz4.LZ4Exception, .LZ4Factory, .LZ4FastDecompressor, java.util.function.Supplier, java.util.zip.Checksum

Uncompresses a Buffer encoded with 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 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
Lz4Decompressor.State

Current state of stream.

Field Summary

Modifier and TypeField and Description
private int
blockType

Type of current block.

private BufferChecksum
checksum

Underlying checksum calculator in use.

private int
compressedLength

Compressed length of current incoming block.

private int
currentChecksum

Checksum value of current incoming block.

private Lz4Decompressor.State
private int
decompressedLength

Decompressed length of current incoming block.

private LZ4FastDecompressor
decompressor

Underlying decompressor in use.

Constructor Summary

AccessConstructor and Description
private
Lz4Decompressor(LZ4Factory
user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the sun.misc.Unsafe
factory
,
Checksum
the Checksum instance to use to check data for integrity. You may set null if you do not want to validate checksum of each block
checksum
)

Creates a new customizable LZ4 decompressor factory.

Method Summary

Modifier and TypeMethod and Description
public void
private void
decompress(Buffer compressed, Buffer uncompressed)

public Buffer
decompress(Buffer
the Buffer that contains the data to be decompressed.
in
,
BufferAllocator
the BufferAllocator that is used to allocate a new buffer (if needed) to write the decompressed bytes too.
allocator
)

Implements io.netty5.handler.codec.compression.Decompressor.decompress.

This method will read from the input Buffer and decompress into a new Buffer that will be allocated (if needed) from the BufferAllocator.
public boolean
isClosed()

Implements io.netty5.handler.codec.compression.Decompressor.isClosed.

Return true if the decompressor was closed, false otherwise.
public boolean
isFinished()

Implements io.netty5.handler.codec.compression.Decompressor.isFinished.

Returns true if the decompressor was finish.
public static Supplier<Lz4Decompressor>

Returns:

the factory.
newFactory
()

Creates the fastest LZ4 decompressor factory.

public static Supplier<Lz4Decompressor>

Returns:

the factory.
newFactory
(boolean
if true, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitable DecompressionException will be thrown
validateChecksums
)

Creates a LZ4 decompressor factory with fastest decoder instance available on your machine.

public static Supplier<Lz4Decompressor>

Returns:

the factory.
newFactory
(LZ4Factory
user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the sun.misc.Unsafe
factory
,
boolean
if true, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitable DecompressionException will be thrown. In this case encoder will use xxhash hashing for Java, based on Yann Collet's work available at Github.
validateChecksums
)

Creates a LZ4 decompressor factory with customizable implementation.

public static Supplier<Lz4Decompressor>

Returns:

the factory.
newFactory
(LZ4Factory
user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the sun.misc.Unsafe
factory
,
Checksum
the Checksum instance to use to check data for integrity. You may set null if you do not want to validate checksum of each block
checksum
)

Creates a customizable LZ4 decompressor factory.

private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockTypeback to summary
private int blockType

Type of current block.

checksumback to summary
private BufferChecksum checksum

Underlying checksum calculator in use.

compressedLengthback to summary
private int compressedLength

Compressed length of current incoming block.

currentChecksumback to summary
private int currentChecksum

Checksum value of current incoming block.

currentStateback to summary
private Lz4Decompressor.State currentState
decompressedLengthback to summary
private int decompressedLength

Decompressed length of current incoming block.

decompressorback to summary
private LZ4FastDecompressor decompressor

Deprecated

as a consequence of LZ4FastDecompressor being deprecated. See corresponding docs for further information.

Underlying decompressor in use.

Constructor Detail

Lz4Decompressorback to summary
private Lz4Decompressor(LZ4Factory factory, Checksum checksum)

Creates a new customizable LZ4 decompressor factory.

Parameters
factory:LZ4Factory

user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the sun.misc.Unsafe

checksum:Checksum

the Checksum instance to use to check data for integrity. You may set null if you do not want to validate checksum of each block

Method Detail

closeback to summary
public void close()

Implements io.netty5.handler.codec.compression.Decompressor.close.

Doc from io.netty5.handler.codec.compression.Decompressor.close.

Close the decompressor. After this method was called isFinished() will return true as well and it is not allowed to call decompress(Buffer, BufferAllocator) anymore.

Annotations
@Override
decompressback to summary
private void decompress(Buffer compressed, Buffer uncompressed)
decompressback to summary
public Buffer decompress(Buffer in, BufferAllocator allocator) throws DecompressionException

Implements io.netty5.handler.codec.compression.Decompressor.decompress.

Doc from io.netty5.handler.codec.compression.Decompressor.decompress.

This method will read from the input Buffer and decompress into a new Buffer that will be allocated (if needed) from the BufferAllocator. If there is not enough readable data in the Buffer to process it will return null. This method should be called in a loop as long:

    • something was read from the input
      something was returned
  • Otherwise this method should be called again once there is more data in the input buffer.
    Parameters
    in:Buffer

    the Buffer that contains the data to be decompressed.

    allocator:BufferAllocator

    the BufferAllocator that is used to allocate a new buffer (if needed) to write the decompressed bytes too.

    Returns:Buffer

    the Buffer that contains the decompressed data. The caller of this method takes ownership of the buffer. The return value will be null if there is not enough data readable in the input to make any progress. In this case the user should call it again once there is more data ready to be consumed.

    Annotations
    @Override
    Exceptions
    DecompressionException:
    thrown if an decompression error was encountered or the decompressor was closed before.
    isClosedback to summary
    public boolean isClosed()

    Implements io.netty5.handler.codec.compression.Decompressor.isClosed.

    Doc from io.netty5.handler.codec.compression.Decompressor.isClosed.

    Return true if the decompressor was closed, false otherwise.

    Returns:boolean

    if close() was called.

    Annotations
    @Override
    isFinishedback to summary
    public boolean isFinished()

    Implements io.netty5.handler.codec.compression.Decompressor.isFinished.

    Doc from io.netty5.handler.codec.compression.Decompressor.isFinished.

    Returns true if the decompressor was finish. This might be because the decompressor was explicitly closed or the end of the compressed stream was detected.

    Returns:boolean

    true if the decompressor is done with decompressing the stream.

    Annotations
    @Override
    newFactoryback to summary
    public static Supplier<Lz4Decompressor> newFactory()

    Creates the fastest LZ4 decompressor factory. Note that by default, validation of the checksum header in each chunk is DISABLED for performance improvements. If performance is less of an issue, or if you would prefer the safety that checksum validation brings, please use the newFactory(boolean) constructor with the argument set to true.

    Returns:Supplier<Lz4Decompressor>

    the factory.

    newFactoryback to summary
    public static Supplier<Lz4Decompressor> newFactory(boolean validateChecksums)

    Creates a LZ4 decompressor factory with fastest decoder instance available on your machine.

    Parameters
    validateChecksums:boolean

    if true, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitable DecompressionException will be thrown

    Returns:Supplier<Lz4Decompressor>

    the factory.

    newFactoryback to summary
    public static Supplier<Lz4Decompressor> newFactory(LZ4Factory factory, boolean validateChecksums)

    Creates a LZ4 decompressor factory with customizable implementation.

    Parameters
    factory:LZ4Factory

    user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the sun.misc.Unsafe

    validateChecksums:boolean

    if true, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitable DecompressionException will be thrown. In this case encoder will use xxhash hashing for Java, based on Yann Collet's work available at Github.

    Returns:Supplier<Lz4Decompressor>

    the factory.

    newFactoryback to summary
    public static Supplier<Lz4Decompressor> newFactory(LZ4Factory factory, Checksum checksum)

    Creates a customizable LZ4 decompressor factory.

    Parameters
    factory:LZ4Factory

    user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the sun.misc.Unsafe

    checksum:Checksum

    the Checksum instance to use to check data for integrity. You may set null if you do not want to validate checksum of each block

    Returns:Supplier<Lz4Decompressor>

    the factory.

    streamCorruptedback to summary
    private void streamCorrupted(String message)
    streamCorruptedback to summary
    private void streamCorrupted(Exception cause)
    io.netty5.handler.codec.compression back to summary

    private final Enum Lz4Decompressor.State

    extends Enum<Lz4Decompressor.State>
    Class Inheritance

    Current state of stream.

    Field Summary

    Modifier and TypeField and Description
    public static final Lz4Decompressor.State
    public static final Lz4Decompressor.State
    public static final Lz4Decompressor.State
    public static final Lz4Decompressor.State
    public static final Lz4Decompressor.State

    Constructor Summary

    AccessConstructor and Description
    private

    Method Summary

    Modifier and TypeMethod and Description
    public static Lz4Decompressor.State
    public static Lz4Decompressor.State[]
    Inherited from java.lang.Enum:
    clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

    Field Detail

    CLOSEDback to summary
    public static final Lz4Decompressor.State CLOSED
    CORRUPTEDback to summary
    public static final Lz4Decompressor.State CORRUPTED
    DECOMPRESS_DATAback to summary
    public static final Lz4Decompressor.State DECOMPRESS_DATA
    FINISHEDback to summary
    public static final Lz4Decompressor.State FINISHED
    INIT_BLOCKback to summary
    public static final Lz4Decompressor.State INIT_BLOCK

    Constructor Detail

    Stateback to summary
    private State()

    Method Detail

    valueOfback to summary
    public static Lz4Decompressor.State valueOf(String name)
    valuesback to summary
    public static Lz4Decompressor.State[] values()