MCPcopy Create free account
hub / github.com/OpenTSDB/asynchbase / readProtoBufVarint

Method readProtoBufVarint

src/HBaseRpc.java:1358–1386  ·  view source on GitHub ↗

Reads a 32-bit variable-length integer value as used in Protocol Buffers. @param buf The buffer to read from. @return The integer read.

(final ChannelBuffer buf)

Source from the content-addressed store, hash-verified

1356 * @return The integer read.
1357 */
1358 static int readProtoBufVarint(final ChannelBuffer buf) {
1359 int result = buf.readByte();
1360 if (result >= 0) {
1361 return result;
1362 }
1363 result &= 0x7F;
1364 result |= buf.readByte() << 7;
1365 if (result >= 0) {
1366 return result;
1367 }
1368 result &= 0x3FFF;
1369 result |= buf.readByte() << 14;
1370 if (result >= 0) {
1371 return result;
1372 }
1373 result &= 0x1FFFFF;
1374 result |= buf.readByte() << 21;
1375 if (result >= 0) {
1376 return result;
1377 }
1378 result &= 0x0FFFFFFF;
1379 final byte b = buf.readByte();
1380 result |= b << 28;
1381 if (b >= 0) {
1382 return result;
1383 }
1384 throw new IllegalArgumentException("Not a 32 bit varint: " + result
1385 + " (5th byte: " + b + ")");
1386 }
1387
1388}

Callers 2

serdesOrderingMethod · 0.95
readProtobufMethod · 0.95

Calls

no outgoing calls

Tested by 1

serdesOrderingMethod · 0.76