acid icon indicating copy to clipboard operation
acid copied to clipboard

More efficient variable-length integer keys

Open dw opened this issue 12 years ago • 0 comments

The current encoding throws away a byte for every integer encoded: since only 10 values of the discriminator byte are currently used.

We could instead collapse the first byte of the integer at least partially into the discriminator, say as:

  • 10==NEG_INT3 -> next 3 bytes are -65535..0xffffff
  • 11==NEG_INT2 -> next 2 bytes are -256..65535
  • 12==NEG_INT1 -> next byte is -0..255
  • 13==INT1 -> next byte is 0..255
  • 14==INT2 -> next 2 bytes are 256..65535
  • 15==INT3 -> next 3 bytes are 65535..0xffffff

etc.

A separate varint encoding might still needed for e.g. allocating encoding prefixes, but there are alternative solutions for that

dw avatar Aug 20 '13 17:08 dw