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

public final Class SnappyDecompressor

extends Object
implements Decompressor
Class Inheritance
All Implemented Interfaces
io.netty5.handler.codec.compression.Decompressor, java.lang.AutoCloseable
Imports
io.netty5.buffer.BufferUtil, .Buffer, .BufferAllocator, java.util.function.Supplier

Uncompresses a Buffer encoded with the Snappy framing format. See Snappy framing format. 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 SnappyDecompressor(boolean) constructor with the argument set to true.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
private static enum

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private int
private final Snappy
private static final int
private boolean
private SnappyDecompressor.State
private final boolean

Constructor Summary

AccessConstructor and Description
private
SnappyDecompressor(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 new snappy decompressor with validation of checksums as specified.

Method Summary

Modifier and TypeMethod and Description
private static void
checkByte(byte actual, byte expect)

public void
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.
private static SnappyDecompressor.ChunkType

Returns:

The appropriate ChunkType, defaulting to ChunkType#RESERVED_UNSKIPPABLE
mapChunkType
(byte
The tag byte extracted from the stream
type
)

Decodes the chunk type from the type tag byte.

public static Supplier<SnappyDecompressor>

Returns:

the factory.
newFactory
()

Creates a new snappy decompressor factory with validation of checksums turned OFF.

public static Supplier<SnappyDecompressor>

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 new snappy decompressor factory with validation of checksums as specified.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MAX_COMPRESSED_CHUNK_SIZEback to summary
private static final int MAX_COMPRESSED_CHUNK_SIZE
MAX_DECOMPRESSED_DATA_SIZEback to summary
private static final int MAX_DECOMPRESSED_DATA_SIZE
MAX_UNCOMPRESSED_DATA_SIZEback to summary
private static final int MAX_UNCOMPRESSED_DATA_SIZE
numBytesToSkipback to summary
private int numBytesToSkip
snappyback to summary
private final Snappy snappy
SNAPPY_IDENTIFIER_LENback to summary
private static final int SNAPPY_IDENTIFIER_LEN
startedback to summary
private boolean started
stateback to summary
private SnappyDecompressor.State state
validateChecksumsback to summary
private final boolean validateChecksums

Constructor Detail

SnappyDecompressorback to summary
private SnappyDecompressor(boolean validateChecksums)

Creates a new snappy decompressor with validation of checksums as specified.

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

Method Detail

checkByteback to summary
private static void checkByte(byte actual, byte expect)
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
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
    mapChunkTypeback to summary
    private static SnappyDecompressor.ChunkType mapChunkType(byte type)

    Decodes the chunk type from the type tag byte.

    Parameters
    type:byte

    The tag byte extracted from the stream

    Returns:SnappyDecompressor.ChunkType

    The appropriate ChunkType, defaulting to ChunkType#RESERVED_UNSKIPPABLE

    newFactoryback to summary
    public static Supplier<SnappyDecompressor> newFactory()

    Creates a new snappy decompressor factory with validation of checksums turned OFF. To turn checksum validation on, please use the alternate SnappyDecompressor(boolean) constructor.

    Returns:Supplier<SnappyDecompressor>

    the factory.

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

    Creates a new snappy decompressor factory with validation of checksums as specified.

    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<SnappyDecompressor>

    the factory.

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

    private final Enum SnappyDecompressor.ChunkType

    extends Enum<SnappyDecompressor.ChunkType>
    Class Inheritance

    Field Summary

    Modifier and TypeField and Description
    public static final SnappyDecompressor.ChunkType
    public static final SnappyDecompressor.ChunkType
    public static final SnappyDecompressor.ChunkType
    public static final SnappyDecompressor.ChunkType
    public static final SnappyDecompressor.ChunkType
    public static final SnappyDecompressor.ChunkType
    public static final SnappyDecompressor.ChunkType

    Constructor Summary

    AccessConstructor and Description
    private

    Method Summary

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

    Field Detail

    COMPRESSED_DATAback to summary
    public static final SnappyDecompressor.ChunkType COMPRESSED_DATA
    CORRUPTEDback to summary
    public static final SnappyDecompressor.ChunkType CORRUPTED
    FINISHEDback to summary
    public static final SnappyDecompressor.ChunkType FINISHED
    RESERVED_SKIPPABLEback to summary
    public static final SnappyDecompressor.ChunkType RESERVED_SKIPPABLE
    RESERVED_UNSKIPPABLEback to summary
    public static final SnappyDecompressor.ChunkType RESERVED_UNSKIPPABLE
    STREAM_IDENTIFIERback to summary
    public static final SnappyDecompressor.ChunkType STREAM_IDENTIFIER
    UNCOMPRESSED_DATAback to summary
    public static final SnappyDecompressor.ChunkType UNCOMPRESSED_DATA

    Constructor Detail

    ChunkTypeback to summary
    private ChunkType()

    Method Detail

    valueOfback to summary
    public static SnappyDecompressor.ChunkType valueOf(String name)
    valuesback to summary
    public static SnappyDecompressor.ChunkType[] values()
    io.netty5.handler.codec.compression back to summary

    private final Enum SnappyDecompressor.State

    extends Enum<SnappyDecompressor.State>
    Class Inheritance

    Field Summary

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

    Constructor Summary

    AccessConstructor and Description
    private

    Method Summary

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

    Field Detail

    CLOSEDback to summary
    public static final SnappyDecompressor.State CLOSED
    CORRUPTEDback to summary
    public static final SnappyDecompressor.State CORRUPTED
    DECODINGback to summary
    public static final SnappyDecompressor.State DECODING
    FINISHEDback to summary
    public static final SnappyDecompressor.State FINISHED

    Constructor Detail

    Stateback to summary
    private State()

    Method Detail

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