Den mån 23 sep. 2019 kl 14:42 skrev Colin McCabe <cmcc...@apache.org>:

> On Fri, Sep 20, 2019, at 18:05, Jun Rao wrote:
> > 101. We already use varInt in the message format. I assume that the
> > protocol uses the same varInt representation?
>
> It uses a slightly different varint representation.  Basically, the
> difference is that the existing representation uses serpentine encoding to
> make representing negative numbers more efficient, at the cost of making
> positive numbers less efficient.  Since tags (and lengths) can't be
> negative, there is no need for serpentine encoding, and we can be more
> efficient without it.
>

While I don't see anything technically wrong with the proposed custom
varint encoding, it does
come at a price since it prevents client developers from using an existing,
tested, and optimized zigzag varint implementation,
and it makes the Kafka protocol more complex by now having 4 ways to encode
integers.

I'm not strongly opposed, but unless there is an actual efficiency gain in
using the custom encoding,
I'd see us using the existing zigzag varint encoding instead, or having the
protocol semantics state
that a zero-sized tag value is the same as null, or that omission of a tag
means null.

//Magnus

Reply via email to