LzfEncoder Class — netty Architecture
Architecture documentation for the LzfEncoder class in LzfEncoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD cf653678_8419_ee5d_5141_4973b04e6b00["LzfEncoder"] d8cdbc33_9249_7654_8d92_05b0f440e74c["LzfEncoder.java"] cf653678_8419_ee5d_5141_4973b04e6b00 -->|defined in| d8cdbc33_9249_7654_8d92_05b0f440e74c 8755c1a0_e89a_639d_8247_88954e9bd55c["LzfEncoder()"] cf653678_8419_ee5d_5141_4973b04e6b00 -->|method| 8755c1a0_e89a_639d_8247_88954e9bd55c 3ba6d3de_599f_0037_5044_8cc82e1307ea["encode()"] cf653678_8419_ee5d_5141_4973b04e6b00 -->|method| 3ba6d3de_599f_0037_5044_8cc82e1307ea 77db0f9f_0817_bb20_ff27_ef4f9b6506c5["encodeCompress()"] cf653678_8419_ee5d_5141_4973b04e6b00 -->|method| 77db0f9f_0817_bb20_ff27_ef4f9b6506c5 3910071b_2c47_0b76_29be_086c744d3370["lzfEncodeNonCompress()"] cf653678_8419_ee5d_5141_4973b04e6b00 -->|method| 3910071b_2c47_0b76_29be_086c744d3370 251e5e57_80da_017e_b324_be7b805a8db5["encodeNonCompress()"] cf653678_8419_ee5d_5141_4973b04e6b00 -->|method| 251e5e57_80da_017e_b324_be7b805a8db5 9b39375b_832f_f69c_5f43_aee66fd379f0["handlerRemoved()"] cf653678_8419_ee5d_5141_4973b04e6b00 -->|method| 9b39375b_832f_f69c_5f43_aee66fd379f0
Relationship Graph
Source Code
codec-compression/src/main/java/io/netty/handler/codec/compression/LzfEncoder.java lines 36–253
public class LzfEncoder extends MessageToByteEncoder<ByteBuf> {
/**
* Minimum block size ready for compression. Blocks with length
* less than {@link #MIN_BLOCK_TO_COMPRESS} will write as uncompressed.
*/
private static final int MIN_BLOCK_TO_COMPRESS = 16;
private static final boolean DEFAULT_SAFE = !PlatformDependent.hasUnsafe();
/**
* 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.
* <p>
* When the value is less than {@see ChunkEncoder#MIN_BLOCK_TO_COMPRESS}, since LZF will not compress data
* that is less than {@see ChunkEncoder#MIN_BLOCK_TO_COMPRESS}, compressThreshold will not work.
*/
private final int compressThreshold;
/**
* Underlying decoder in use.
*/
private final ChunkEncoder encoder;
/**
* Object that handles details of buffer recycling.
*/
private final BufferRecycler recycler;
/**
* 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 {@link #LzfEncoder(boolean)} with {@code true} param.
*/
public LzfEncoder() {
this(DEFAULT_SAFE);
}
/**
* Creates a new LZF encoder with specified encoding instance.
*
* @param safeInstance If {@code true} encoder will use {@link 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 {@link ChunkEncoder}
* implementation that uses Sun JDK's {@link sun.misc.Unsafe}
* class (which may be included by other JDK's as well).
* @deprecated Use the constructor without the {@code safeInstance} parameter.
*/
@Deprecated
public LzfEncoder(boolean safeInstance) {
this(safeInstance, MAX_CHUNK_LEN);
}
/**
* Creates a new LZF encoder with specified encoding instance and compressThreshold.
*
* @param safeInstance If {@code true} encoder will use {@link 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 {@link ChunkEncoder}
* implementation that uses Sun JDK's {@link sun.misc.Unsafe}
* class (which may be included by other JDK's as well).
* @param totalLength 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.
* @deprecated Use the constructor without the {@code safeInstance} parameter.
*/
@Deprecated
public LzfEncoder(boolean safeInstance, int totalLength) {
this(safeInstance, totalLength, MIN_BLOCK_TO_COMPRESS);
}
/**
* 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.
*
* @param totalLength 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.
*/
public LzfEncoder(int totalLength) {
this(DEFAULT_SAFE, totalLength);
}
Source
Frequently Asked Questions
What is the LzfEncoder class?
LzfEncoder is a class in the netty codebase, defined in codec-compression/src/main/java/io/netty/handler/codec/compression/LzfEncoder.java.
Where is LzfEncoder defined?
LzfEncoder is defined in codec-compression/src/main/java/io/netty/handler/codec/compression/LzfEncoder.java at line 36.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free