decode() — netty Function Reference
Architecture documentation for the decode() function in AbstractBinaryMemcacheDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD fc04d2f1_e0ef_815c_2cb1_b5f24e44683e["decode()"] 337c246d_1811_4204_aa58_594cb5d04bc8["AbstractBinaryMemcacheDecoder"] fc04d2f1_e0ef_815c_2cb1_b5f24e44683e -->|defined in| 337c246d_1811_4204_aa58_594cb5d04bc8 af4d9ee7_c660_e32a_59ac_59524875e13b["resetDecoder()"] fc04d2f1_e0ef_815c_2cb1_b5f24e44683e -->|calls| af4d9ee7_c660_e32a_59ac_59524875e13b style fc04d2f1_e0ef_815c_2cb1_b5f24e44683e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java lines 69–167
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
switch (state) {
case READ_HEADER: try {
if (in.readableBytes() < 24) {
return;
}
resetDecoder();
currentMessage = decodeHeader(in);
state = State.READ_EXTRAS;
} catch (Exception e) {
resetDecoder();
out.add(invalidMessage(e));
return;
}
case READ_EXTRAS: try {
byte extrasLength = currentMessage.extrasLength();
if (extrasLength > 0) {
if (in.readableBytes() < extrasLength) {
return;
}
currentMessage.setExtras(in.readRetainedSlice(extrasLength));
}
state = State.READ_KEY;
} catch (Exception e) {
resetDecoder();
out.add(invalidMessage(e));
return;
}
case READ_KEY: try {
short keyLength = currentMessage.keyLength();
if (keyLength > 0) {
if (in.readableBytes() < keyLength) {
return;
}
currentMessage.setKey(in.readRetainedSlice(keyLength));
}
out.add(currentMessage.retain());
state = State.READ_CONTENT;
} catch (Exception e) {
resetDecoder();
out.add(invalidMessage(e));
return;
}
case READ_CONTENT: try {
int valueLength = currentMessage.totalBodyLength()
- currentMessage.keyLength()
- currentMessage.extrasLength();
int toRead = in.readableBytes();
if (valueLength > 0) {
if (toRead == 0) {
return;
}
if (toRead > chunkSize) {
toRead = chunkSize;
}
int remainingLength = valueLength - alreadyReadChunkSize;
if (toRead > remainingLength) {
toRead = remainingLength;
}
ByteBuf chunkBuffer = in.readRetainedSlice(toRead);
MemcacheContent chunk;
if ((alreadyReadChunkSize += toRead) >= valueLength) {
chunk = new DefaultLastMemcacheContent(chunkBuffer);
} else {
chunk = new DefaultMemcacheContent(chunkBuffer);
}
out.add(chunk);
if (alreadyReadChunkSize < valueLength) {
return;
}
} else {
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does decode() do?
decode() is a function in the netty codebase, defined in codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java.
Where is decode() defined?
decode() is defined in codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java at line 69.
What does decode() call?
decode() calls 1 function(s): resetDecoder.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free