List of utility methods to do Type Size
int | sizeOfVarint(int value) Number of bytes needed to encode an integer in variable-length format. int v = (value << 1) ^ (value >> 31); int bytes = 1; while ((v & 0xffffff80) != 0L) { bytes += 1; v >>>= 7; return bytes; |
int | sizeOfWriteLength(int len) size Of Write Length if (len < 0) { throw new RuntimeException("Invalid length < 0"); if (len <= 127) { return 1; } else if (len <= 16383) { return 2; } else if (len <= 2097151) { ... |