encodeAndDecodeLongTextUsesCopy() — netty Function Reference
Architecture documentation for the encodeAndDecodeLongTextUsesCopy() function in SnappyTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 640ea35f_21d9_0736_f78c_94a1829e9b38["encodeAndDecodeLongTextUsesCopy()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675["SnappyTest"] 640ea35f_21d9_0736_f78c_94a1829e9b38 -->|defined in| 1a449087_fef9_c1b9_33e3_88b8aff8d675 style 640ea35f_21d9_0736_f78c_94a1829e9b38 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-compression/src/test/java/io/netty/handler/codec/compression/SnappyTest.java lines 171–248
@Test
public void encodeAndDecodeLongTextUsesCopy() throws Exception {
String srcStr = "Netty has been designed carefully with the experiences " +
"earned from the implementation of a lot of protocols " +
"such as FTP, SMTP, HTTP, and various binary and " +
"text-based legacy protocols";
ByteBuf in = Unpooled.wrappedBuffer(srcStr.getBytes(StandardCharsets.US_ASCII));
ByteBuf out = Unpooled.buffer(180);
snappy.encode(in, out, in.readableBytes());
// The only compressibility in the above are the words:
// "the ", "rotocols", " of ", "TP, " and "and ". So this is a literal,
// followed by a copy followed by another literal, followed by another copy...
ByteBuf expected = Unpooled.wrappedBuffer(new byte[] {
-0x49, 0x01, // preamble length
-0x10, 0x42, // literal tag + length
// Literal
0x4e, 0x65, 0x74, 0x74, 0x79, 0x20, 0x68, 0x61, 0x73, 0x20,
0x62, 0x65, 0x65, 0x6e, 0x20, 0x64, 0x65, 0x73, 0x69, 0x67,
0x6e, 0x65, 0x64, 0x20, 0x63, 0x61, 0x72, 0x65, 0x66, 0x75,
0x6c, 0x6c, 0x79, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74,
0x68, 0x65, 0x20, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x65,
0x6e, 0x63, 0x65, 0x73, 0x20, 0x65, 0x61, 0x72, 0x6e, 0x65,
0x64, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20,
// copy of "the "
0x01, 0x1c, 0x58,
// Next literal
0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x20,
0x6c, 0x6f, 0x74,
// copy of " of "
0x01, 0x09, 0x60,
// literal
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x20,
0x73, 0x75, 0x63, 0x68, 0x20, 0x61, 0x73, 0x20, 0x46, 0x54,
0x50, 0x2c, 0x20, 0x53, 0x4d,
// copy of " TP, "
0x01, 0x06, 0x04,
// literal
0x48, 0x54,
// copy of " TP, "
0x01, 0x06, 0x44,
// literal
0x61, 0x6e, 0x64, 0x20, 0x76, 0x61, 0x72, 0x69, 0x6f, 0x75,
0x73, 0x20, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79,
// copy of "and "
0x05, 0x13, 0x48,
// literal
0x74, 0x65, 0x78, 0x74, 0x2d, 0x62, 0x61, 0x73, 0x65,
0x64, 0x20, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x20, 0x70,
// copy of "rotocols"
0x11, 0x4c,
});
assertEquals(expected, out, "Encoded result was incorrect");
// Decode
ByteBuf outDecoded = Unpooled.buffer();
snappy.decode(out, outDecoded);
assertEquals(CharBuffer.wrap(srcStr),
CharBuffer.wrap(outDecoded.getCharSequence(0, outDecoded.writerIndex(), CharsetUtil.US_ASCII)));
in.release();
out.release();
outDecoded.release();
}
Domain
Subdomains
Source
Frequently Asked Questions
What does encodeAndDecodeLongTextUsesCopy() do?
encodeAndDecodeLongTextUsesCopy() is a function in the netty codebase, defined in codec-compression/src/test/java/io/netty/handler/codec/compression/SnappyTest.java.
Where is encodeAndDecodeLongTextUsesCopy() defined?
encodeAndDecodeLongTextUsesCopy() is defined in codec-compression/src/test/java/io/netty/handler/codec/compression/SnappyTest.java at line 171.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free