readRawVarint32() — netty Function Reference
Architecture documentation for the readRawVarint32() function in ProtobufVarint32FrameDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD bf8c8c02_e669_17c5_7fe4_cb9b825ddb69["readRawVarint32()"] f7621757_c495_a067_dbd2_54254d637829["ProtobufVarint32FrameDecoder"] bf8c8c02_e669_17c5_7fe4_cb9b825ddb69 -->|defined in| f7621757_c495_a067_dbd2_54254d637829 c1590bf2_98a5_65af_00fb_ead73b9ba31d["decode()"] c1590bf2_98a5_65af_00fb_ead73b9ba31d -->|calls| bf8c8c02_e669_17c5_7fe4_cb9b825ddb69 e9cf2283_6346_e220_ecc4_5e58d76b3f5a["readRawVarint24()"] bf8c8c02_e669_17c5_7fe4_cb9b825ddb69 -->|calls| e9cf2283_6346_e220_ecc4_5e58d76b3f5a b8dac422_5bdd_baf1_49bd_e0bbf8d399fa["readRawVarint40()"] bf8c8c02_e669_17c5_7fe4_cb9b825ddb69 -->|calls| b8dac422_5bdd_baf1_49bd_e0bbf8d399fa style bf8c8c02_e669_17c5_7fe4_cb9b825ddb69 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-protobuf/src/main/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoder.java lines 73–98
static int readRawVarint32(ByteBuf buffer) {
if (buffer.readableBytes() < 4) {
return readRawVarint24(buffer);
}
int wholeOrMore = buffer.getIntLE(buffer.readerIndex());
int firstOneOnStop = ~wholeOrMore & 0x80808080;
if (firstOneOnStop == 0) {
return readRawVarint40(buffer, wholeOrMore);
}
int bitsToKeep = Integer.numberOfTrailingZeros(firstOneOnStop) + 1;
buffer.skipBytes(bitsToKeep >> 3);
int thisVarintMask = firstOneOnStop ^ (firstOneOnStop - 1);
int wholeWithContinuations = wholeOrMore & thisVarintMask;
// mix them up as per varint spec while dropping the continuation bits:
// 0x7F007F isolate the first byte and the third byte dropping the continuation bits
// 0x7F007F00 isolate the second byte and the fourth byte dropping the continuation bits
// the second and fourth byte are shifted to the right by 1, filling the gaps left by the first and third byte
// it means that the first and second bytes now occupy the first 14 bits (7 bits each)
// and the third and fourth bytes occupy the next 14 bits (7 bits each), with a gap between the 2s of 2 bytes
// and another gap of 2 bytes after the forth and third.
wholeWithContinuations = (wholeWithContinuations & 0x7F007F) | ((wholeWithContinuations & 0x7F007F00) >> 1);
// 0x3FFF isolate the first 14 bits i.e. the first and second bytes
// 0x3FFF0000 isolate the next 14 bits i.e. the third and forth bytes
// the third and forth bytes are shifted to the right by 2, filling the gaps left by the first and second bytes
return (wholeWithContinuations & 0x3FFF) | ((wholeWithContinuations & 0x3FFF0000) >> 2);
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does readRawVarint32() do?
readRawVarint32() is a function in the netty codebase, defined in codec-protobuf/src/main/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoder.java.
Where is readRawVarint32() defined?
readRawVarint32() is defined in codec-protobuf/src/main/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoder.java at line 73.
What does readRawVarint32() call?
readRawVarint32() calls 2 function(s): readRawVarint24, readRawVarint40.
What calls readRawVarint32()?
readRawVarint32() is called by 1 function(s): decode.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free