# Question about ea7: List for a single partition - Name Length encoding

**URL:** <https://forum.codecrafters.io/t/question-about-ea7-list-for-a-single-partition-name-length-encoding/4477>\
**Category:** Challenges\
**Tags:** challenge:kafka\
**Created:** [January 26, 2025, 12:34pm UTC](https://forum.codecrafters.io/t/question-about-ea7-list-for-a-single-partition-name-length-encoding/4477 "2025-01-26T12:34:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gad](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gad/32/4211_2.png) [@Gad](https://forum.codecrafters.io/u/Gad)\
**Post date:** [January 26, 2025, 12:34pm UTC](https://forum.codecrafters.io/t/question-about-ea7-list-for-a-single-partition-name-length-encoding/4477/1 "2025-01-26T12:34:58Z")

</div>

Hello,  
I don’t get the explanation in the binserve description of this field : there seems to be a contradiction between the sentences.  
I do get 0 (hence -1) but then how am I supposed to deduce the number of bytes to read for the name ?  
Thanks

 ![Sélection_036](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/9/9c4ad78aafbf4aeeba5ca5037aad334befa701cb.png)

Gad

---

<div class="post-metadata">

**Author:** ![LynX-gh](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/lynx-gh/32/3284_2.png) [@LynX-gh](https://forum.codecrafters.io/u/LynX-gh)\
**Post date:** [January 26, 2025, 2:11pm UTC](https://forum.codecrafters.io/t/question-about-ea7-list-for-a-single-partition-name-length-encoding/4477/2 "2025-01-26T14:11:31Z")

</div>

Name length is a “varint” and unfortunately codecrafters have not provided any proper explaination of varints in the course or the BinSpec  
The only way currently is google it and try to figure out or look at how someone else has read these values

---

<div class="post-metadata">

**Author:** ![Gad](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gad/32/4211_2.png) [@Gad](https://forum.codecrafters.io/u/Gad)\
**Post date:** [January 26, 2025, 2:44pm UTC](https://forum.codecrafters.io/t/question-about-ea7-list-for-a-single-partition-name-length-encoding/4477/3 "2025-01-26T14:44:02Z")

</div>

Thanks, I thought I was fine with varint : the pointers given ([here](https://protobuf.dev/programming-guides/encoding/) for the msb parsing and bytes concatenation and [here](https://kafka.apache.org/protocol.html#protocol_types) for the zigzag encoding itself when signed) were enough so far, although I may have wrongly deduced that when unsigned, we need to skip the zigzag decoding.  
Anyway, here my issue is that one sentence says we should always read -1 and the next one says we should read a proper length

---

<div class="post-metadata">

**Author:** ![LynX-gh](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/lynx-gh/32/3284_2.png) [@LynX-gh](https://forum.codecrafters.io/u/LynX-gh)\
**Post date:** [January 26, 2025, 2:56pm UTC](https://forum.codecrafters.io/t/question-about-ea7-list-for-a-single-partition-name-length-encoding/4477/4 "2025-01-26T14:56:12Z")

</div>

Since it is a compact string the length of the string will be `varint - 1`

> ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/d/de30e806288a782316c89ea74b1833fc9b0ac392.png)  
> From the Kafka Docs

---

<div class="post-metadata">

**Author:** ![Gad](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gad/32/4211_2.png) [@Gad](https://forum.codecrafters.io/u/Gad)\
**Post date:** [January 26, 2025, 3:10pm UTC](https://forum.codecrafters.io/t/question-about-ea7-list-for-a-single-partition-name-length-encoding/4477/5 "2025-01-26T15:10:23Z")

</div>

Ok, I get it : my bad, I read “is always length = -1” instead of “is always length -1”. I just invented the “=”, lol  
Thanks for your help !

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [March 10, 2025, 9:46am UTC](https://forum.codecrafters.io/t/question-about-ea7-list-for-a-single-partition-name-length-encoding/4477/6 "2025-03-10T09:46:10Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
