public class SnappyFrameEncoder extends MessageToByteEncoder<ByteBuf>
ByteBuf using the Snappy framing format.
See Snappy framing format.ChannelHandler.Sharable| Modifier and Type | Field and Description |
|---|---|
private static int |
MIN_COMPRESSIBLE_LENGTH
The minimum amount that we'll consider actually attempting to compress.
|
private Snappy |
snappy |
private boolean |
started |
private static byte[] |
STREAM_START
All streams should start with the "Stream identifier", containing chunk
type 0xff, a length field of 0x6, and 'sNaPpY' in ASCII.
|
| Constructor and Description |
|---|
SnappyFrameEncoder() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
calculateAndWriteChecksum(ByteBuf slice,
ByteBuf out)
Calculates and writes the 4-byte checksum to the output buffer
|
protected void |
encode(ChannelHandlerContext ctx,
ByteBuf in,
ByteBuf out)
Encode a message into a
ByteBuf. |
private static void |
setChunkLength(ByteBuf out,
int lengthIdx) |
private static void |
writeChunkLength(ByteBuf out,
int chunkLength)
Writes the 2-byte chunk length to the output buffer.
|
private static void |
writeUnencodedChunk(ByteBuf in,
ByteBuf out,
int dataLength) |
acceptOutboundMessage, allocateBuffer, isPreferDirect, writebind, close, connect, deregister, disconnect, flush, readensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexceptionCaught, handlerAdded, handlerRemovedprivate static final int MIN_COMPRESSIBLE_LENGTH
private static final byte[] STREAM_START
private final Snappy snappy
private boolean started
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws java.lang.Exception
MessageToByteEncoderByteBuf. This method will be called for each written message that can be handled
by this encoder.encode in class MessageToByteEncoder<ByteBuf>ctx - the ChannelHandlerContext which this MessageToByteEncoder belongs toin - the message to encodeout - the ByteBuf into which the encoded message will be writtenjava.lang.Exception - is thrown if an error occursprivate static void writeUnencodedChunk(ByteBuf in, ByteBuf out, int dataLength)
private static void setChunkLength(ByteBuf out, int lengthIdx)
private static void writeChunkLength(ByteBuf out, int chunkLength)
out - The buffer to write tochunkLength - The length to write