in hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/util/BytesBuffer.java [653:699]
private long readNumber(byte b) {
E.checkArgument((b & 0x80) == 0,
"Not a number type with prefix byte '0x%s'",
Bytes.toHex(b));
// Parse the kind from byte 0kkksxxx
int kind = b >>> 4;
boolean positive = (b & 0x08) > 0;
long high3bits = b & 0x07;
long value = high3bits << ((kind + 1) * 8);
switch (kind) {
case 0:
value |= this.readUInt8();
break;
case 1:
value |= this.readUInt16();
break;
case 2:
value |= this.readUInt8() << 16 | this.readUInt16();
break;
case 3:
value |= this.readUInt32();
break;
case 4:
value |= (long) this.readUInt8() << 32 | this.readUInt32();
break;
case 5:
value |= (long) this.readUInt16() << 32 | this.readUInt32();
break;
case 6:
value |= (long) this.readUInt8() << 48 |
(long) this.readUInt16() << 32 |
this.readUInt32();
break;
case 7:
assert high3bits == 0L;
value |= this.readLong();
break;
default:
throw new AssertionError("Invalid length of number: " + kind);
}
if (!positive && kind < 7) {
// Restore the bits of the original negative number
long mask = Long.MIN_VALUE >> (52 - kind * 8);
value |= mask;
}
return value;
}