Search code examples
flatbuffers

Does Flatbuffer use integer bit packing encoding like protobuf?


Does flatbuffers employ any special encoding for integers or other types, like Protobufs does for integers with zigzag + packing? This can be a huge space savings. I can't find any reference in the documentation one way or another.


Solution

  • No, it doesn't, since FlatBuffers is optimized for direct access, much like structs/arrays in programming languages. Protobuf varints can take up to 10x longer to decode than just reading a scalar from memory, and depending on the use case, also make it harder to access randomly (such as inside an array).

    That said, it be a nice optional feature to have, and was already hinted at here: https://github.com/google/flatbuffers/issues/5875. You could open an issue/PR about it if you find it really important.