encode() — netty Function Reference
Architecture documentation for the encode() function in Bzip2Encoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 35e37b6a_cb9e_fb64_b499_c94674308a46["encode()"] f5a67cba_5005_73f8_aa68_98f6f92e4a9a["Bzip2Encoder"] 35e37b6a_cb9e_fb64_b499_c94674308a46 -->|defined in| f5a67cba_5005_73f8_aa68_98f6f92e4a9a 493c0913_17c0_d05d_64f9_62bdd17d5666["closeBlock()"] 35e37b6a_cb9e_fb64_b499_c94674308a46 -->|calls| 493c0913_17c0_d05d_64f9_62bdd17d5666 style 35e37b6a_cb9e_fb64_b499_c94674308a46 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-compression/src/main/java/io/netty/handler/codec/compression/Bzip2Encoder.java lines 105–149
@Override
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception {
if (finished) {
out.writeBytes(in);
return;
}
for (;;) {
switch (currentState) {
case INIT:
out.ensureWritable(4);
out.writeMedium(MAGIC_NUMBER);
out.writeByte('0' + streamBlockSize / BASE_BLOCK_SIZE);
currentState = State.INIT_BLOCK;
// fall through
case INIT_BLOCK:
blockCompressor = new Bzip2BlockCompressor(writer, streamBlockSize);
currentState = State.WRITE_DATA;
// fall through
case WRITE_DATA:
if (!in.isReadable()) {
return;
}
Bzip2BlockCompressor blockCompressor = this.blockCompressor;
final int length = Math.min(in.readableBytes(), blockCompressor.availableSize());
final int bytesWritten = blockCompressor.write(in, in.readerIndex(), length);
in.skipBytes(bytesWritten);
if (!blockCompressor.isFull()) {
if (in.isReadable()) {
break;
} else {
return;
}
}
currentState = State.CLOSE_BLOCK;
// fall through
case CLOSE_BLOCK:
closeBlock(out);
currentState = State.INIT_BLOCK;
break;
default:
throw new IllegalStateException();
}
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does encode() do?
encode() is a function in the netty codebase, defined in codec-compression/src/main/java/io/netty/handler/codec/compression/Bzip2Encoder.java.
Where is encode() defined?
encode() is defined in codec-compression/src/main/java/io/netty/handler/codec/compression/Bzip2Encoder.java at line 105.
What does encode() call?
encode() calls 1 function(s): closeBlock.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free