How to parse variable sized integer from metadata log

It’s the Calculator app on mac in programmer mode:


You’re absolutely right! It’s 257. I was a bit confused as well, because the length of Value (Partition Record) is apparently 65 (= 1 + 16 x 4):

Turns out that VARINT in Kafka involves two additional considerations:

  1. Small/Big-endian order
  2. Zig-zag encoding
000 0010 + 000 0001 reverses order due to endianness:

000 0001 + 000 0010

= 1 000 0010 = 130

130 becomes 130 / 2 = 65 due to zig-zag encoding.