In the challenge List for an unknown topic #vt6
, why is the null byte for the cursor 0xff? It does not seem like a valid value to represent a null value in kafka. I would expect to get a byte that represents a length of -1 if we have no cursor. (I mean an unsigned var int)
Hey @LuisBarroso37, great intuition! 0xff can indeed represent -1 in some context.
Here’s a question: how does a computer represents -1 in binary?
- signed 8-bit: -1 =
11111111
=0xF
Is the cursor a signed var int then? I am currently parsing it as an unsigned var int since we use that for most other primitive values like compact string, compact array, etc. When reading the kafka documentation it is not really clear what the type is for the cursor when it is null.
What I am doing is I try to parse a compact string for the topic name and if the length is 0 then I know the cursor is null.
How should I parse the cursor?
Is the cursor a signed var int then?
No, the cursor isn’t a varint. It starts with a signed INT8
followed by the actual cursor bytes.
How should I parse the cursor?
You can assume it’s always null in our tests.
For reference, see our tester’s implementation of non-null cursor parsing:
Thank you for the help! Now I understand what I must do
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.