ByteBuf using the LZF format.
See original LZF package and LZF format for full description.
| Modifier and Type | Field and Description |
|---|---|
| private final int | compressThreshold
Compress threshold for LZF format. |
| private final ChunkEncoder | encoder
Underlying decoder in use. |
| private static final int | MIN_BLOCK_TO_COMPRESS
Minimum block size ready for compression. |
| private final BufferRecycler | recycler
Object that handles details of buffer recycling. |
| Access | Constructor and Description |
|---|---|
| public | LzfEncoder()
Creates a new LZF encoder with the most optimal available methods for underlying data access. |
| public | LzfEncoder(boolean
If safeInstance)true encoder will use ChunkEncoder that only uses
standard JDK access methods, and should work on all Java platforms and JVMs.
Otherwise encoder will try to use highly optimized ChunkEncoder
implementation that uses Sun JDK's sun.
class (which may be included by other JDK's as well).Creates a new LZF encoder with specified encoding instance. |
| public | LzfEncoder(boolean
If safeInstance, int true encoder will use ChunkEncoder that only uses standard
JDK access methods, and should work on all Java platforms and JVMs.
Otherwise encoder will try to use highly optimized ChunkEncoder
implementation that uses Sun JDK's sun.
class (which may be included by other JDK's as well).Expected total length of content to compress; only matters for outgoing messages
that is smaller than maximum chunk size (64k), to optimize encoding hash tables. totalLength)Creates a new LZF encoder with specified encoding instance and compressThreshold. |
| public | LzfEncoder(int
Expected total length of content to compress;
only matters for outgoing messages that is smaller than maximum chunk size (64k),
to optimize encoding hash tables. totalLength)Creates a new LZF encoder with specified total length of encoded chunk. |
| public | LzfEncoder(boolean
If safeInstance, int true encoder will use ChunkEncoder that only uses standard JDK
access methods, and should work on all Java platforms and JVMs.
Otherwise encoder will try to use highly optimized ChunkEncoder
implementation that uses Sun JDK's sun.
class (which may be included by other JDK's as well).Expected total length of content to compress; only matters for outgoing messages
that is smaller than maximum chunk size (64k), to optimize encoding hash tables. totalLength, int Compress threshold for LZF format. When the amount of input data is less than
compressThreshold, we will construct an uncompressed output according
to the LZF format. compressThreshold)Creates a new LZF encoder with specified settings. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | encode(ChannelHandlerContext
the ctx, ByteBuf ChannelHandlerContext which this MessageToByteEncoder belongs tothe message to encode in, ByteBuf the out)ByteBuf into which the encoded message will be writtenImplements abstract io. ByteBuf.
|
| private int | |
| private static int | encodeNonCompress(byte[] input, int inputPtr, int length, byte[] output, int outputPtr)
Use lzf uncompressed format to encode a piece of input. |
| public void | handlerRemoved(ChannelHandlerContext ctx)
Overrides io. Implements io. ChannelHandler was removed from the actual context and it doesn't handle events
anymore.
|
| private static int |
| compressThreshold | back to summary |
|---|---|
| private final int compressThreshold Compress threshold for LZF format. When the amount of input data is less than compressThreshold, we will construct an uncompressed output according to the LZF format.
When the value is less than
| |
| encoder | back to summary |
|---|---|
| private final ChunkEncoder encoder Underlying decoder in use. | |
| MIN_BLOCK_TO_COMPRESS | back to summary |
|---|---|
| private static final int MIN_BLOCK_TO_COMPRESS Minimum block size ready for compression. Blocks with length
less than | |
| recycler | back to summary |
|---|---|
| private final BufferRecycler recycler Object that handles details of buffer recycling. | |
| LzfEncoder | back to summary |
|---|---|
| public LzfEncoder() Creates a new LZF encoder with the most optimal available methods for underlying data access.
It will "unsafe" instance if one can be used on current JVM.
It should be safe to call this constructor as implementations are dynamically loaded; however, on some
non-standard platforms it may be necessary to use | |
| LzfEncoder | back to summary |
|---|---|
| public LzfEncoder(boolean safeInstance) Creates a new LZF encoder with specified encoding instance.
| |
| LzfEncoder | back to summary |
|---|---|
| public LzfEncoder(boolean safeInstance, int totalLength) Creates a new LZF encoder with specified encoding instance and compressThreshold.
| |
| LzfEncoder | back to summary |
|---|---|
| public LzfEncoder(int totalLength) Creates a new LZF encoder with specified total length of encoded chunk. You can configure it to encode your data flow more efficient if you know the average size of messages that you send.
| |
| LzfEncoder | back to summary |
|---|---|
| public LzfEncoder(boolean safeInstance, int totalLength, int compressThreshold) Creates a new LZF encoder with specified settings.
| |
| encode | back to summary |
|---|---|
| protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception Implements abstract io. Doc from io. Encode a message into a
| |
| encodeCompress | back to summary |
|---|---|
| private int encodeCompress(byte[] input, int inputPtr, int length, byte[] output, int outputPtr) | |
| encodeNonCompress | back to summary |
|---|---|
| private static int encodeNonCompress(byte[] input, int inputPtr, int length, byte[] output, int outputPtr) Use lzf uncompressed format to encode a piece of input. | |
| handlerRemoved | back to summary |
|---|---|
| public void handlerRemoved(ChannelHandlerContext ctx) throws Exception Overrides io. Implements io. Doc from io. Gets called after the
| |
| lzfEncodeNonCompress | back to summary |
|---|---|
| private static int lzfEncodeNonCompress(byte[] input, int inputPtr, int length, byte[] output, int outputPtr) | |