writeTLong

fun writeTLong(out: DataOutput, l: Long)

Writes a long in a variable-length format. Writes between one and ten bytes. Small values or values representing timestamps with day, hour or second precision typically require fewer bytes.

ZLong --> Header, Bytes*

  • Header --> The first two bits indicate the compression scheme:

  • 00 - uncompressed

  • 01 - multiple of 1000 (second)

  • 10 - multiple of 3600000 (hour)

  • 11 - multiple of 86400000 (day)

Then the next bit is a continuation bit, indicating whether more bytes need to be read, and the last 5 bits are the lower bits of the encoded value. In order to reconstruct the value, you need to combine the 5 lower bits of the header with a vLong in the next bytes (if the continuation bit is set to 1). Then zigzag-decode it and finally multiply by the multiple corresponding to the compression scheme.

  • Bytes --> Potential additional bytes to read depending on the header.