decode() — netty Function Reference
Architecture documentation for the decode() function in ZstdDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD f555e463_8e43_f330_5dfd_60bfd5ae66b3["decode()"] ff420528_d442_7376_2907_d6bc00ce06b0["ZstdDecoder"] f555e463_8e43_f330_5dfd_60bfd5ae66b3 -->|defined in| ff420528_d442_7376_2907_d6bc00ce06b0 style f555e463_8e43_f330_5dfd_60bfd5ae66b3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-compression/src/main/java/io/netty/handler/codec/compression/ZstdDecoder.java lines 67–122
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
needsRead = true;
try {
if (currentState == State.CORRUPTED) {
in.skipBytes(in.readableBytes());
return;
}
inputStream.current = in;
ByteBuf outBuffer = null;
final int compressedLength = in.readableBytes();
try {
long uncompressedLength;
if (in.isDirect()) {
uncompressedLength = com.github.luben.zstd.Zstd.getFrameContentSize(
CompressionUtil.safeNioBuffer(in, in.readerIndex(), in.readableBytes()));
} else {
uncompressedLength = com.github.luben.zstd.Zstd.getFrameContentSize(
in.array(), in.readerIndex() + in.arrayOffset(), in.readableBytes());
}
if (uncompressedLength <= 0) {
// Let's start with the compressedLength * 2 as often we will not have everything
// we need in the in buffer and don't want to reserve too much memory.
uncompressedLength = compressedLength * 2L;
}
int w;
do {
if (outBuffer == null) {
outBuffer = ctx.alloc().heapBuffer((int) (maximumAllocationSize == 0 ?
uncompressedLength : Math.min(maximumAllocationSize, uncompressedLength)));
}
do {
w = outBuffer.writeBytes(zstdIs, outBuffer.writableBytes());
} while (w != -1 && outBuffer.isWritable());
if (outBuffer.isReadable()) {
needsRead = false;
ctx.fireChannelRead(outBuffer);
outBuffer = null;
}
} while (w != -1);
} finally {
if (outBuffer != null) {
outBuffer.release();
}
}
} catch (Exception e) {
currentState = State.CORRUPTED;
throw new DecompressionException(e);
} finally {
inputStream.current = null;
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does decode() do?
decode() is a function in the netty codebase, defined in codec-compression/src/main/java/io/netty/handler/codec/compression/ZstdDecoder.java.
Where is decode() defined?
decode() is defined in codec-compression/src/main/java/io/netty/handler/codec/compression/ZstdDecoder.java at line 67.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free