public class SnappyFrameDecoder extends ByteToMessageDecoder
ByteBuf 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 SnappyFrameDecoder(boolean) constructor with the argument
set to true.| Modifier and Type | Class and Description |
|---|---|
private static class |
SnappyFrameDecoder.ChunkType |
ByteToMessageDecoder.CumulatorChannelHandler.Sharable| Modifier and Type | Field and Description |
|---|---|
private boolean |
corrupted |
private static int |
MAX_UNCOMPRESSED_DATA_SIZE |
private Snappy |
snappy |
private static int |
SNAPPY_IDENTIFIER_LEN |
private boolean |
started |
private boolean |
validateChecksums |
COMPOSITE_CUMULATOR, MERGE_CUMULATOR| Constructor and Description |
|---|
SnappyFrameDecoder()
Creates a new snappy-framed decoder with validation of checksums
turned OFF.
|
SnappyFrameDecoder(boolean validateChecksums)
Creates a new snappy-framed decoder with validation of checksums
as specified.
|
| Modifier and Type | Method and Description |
|---|---|
private static void |
checkByte(byte actual,
byte expect) |
protected void |
decode(ChannelHandlerContext ctx,
ByteBuf in,
java.util.List<java.lang.Object> out)
Decode the from one
ByteBuf to an other. |
private static SnappyFrameDecoder.ChunkType |
mapChunkType(byte type)
Decodes the chunk type from the type tag byte.
|
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredchannelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtensureNotSharable, handlerAdded, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAddedprivate static final int SNAPPY_IDENTIFIER_LEN
private static final int MAX_UNCOMPRESSED_DATA_SIZE
private final Snappy snappy
private final boolean validateChecksums
private boolean started
private boolean corrupted
public SnappyFrameDecoder()
SnappyFrameDecoder(boolean) constructor.public SnappyFrameDecoder(boolean validateChecksums)
validateChecksums - 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 thrownprotected void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
ByteToMessageDecoderByteBuf to an other. This method will be called till either the input
ByteBuf has nothing to read when return from this method or till nothing was read from the input
ByteBuf.decode in class ByteToMessageDecoderctx - the ChannelHandlerContext which this ByteToMessageDecoder belongs toin - the ByteBuf from which to read dataout - the List to which decoded messages should be addedjava.lang.Exception - is thrown if an error occursprivate static void checkByte(byte actual,
byte expect)
private static SnappyFrameDecoder.ChunkType mapChunkType(byte type)
type - The tag byte extracted from the streamSnappyFrameDecoder.ChunkType, defaulting to SnappyFrameDecoder.ChunkType.RESERVED_UNSKIPPABLE