# List for multiple partitions #ku4

**URL:** <https://forum.codecrafters.io/t/list-for-multiple-partitions-ku4/7116>\
**Category:** Challenges\
**Tags:** challenge:kafka\
**Created:** [March 19, 2025, 1:53am UTC](https://forum.codecrafters.io/t/list-for-multiple-partitions-ku4/7116 "2025-03-19T01:53:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rishilss99](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rishilss99/32/5137_2.png) [@rishilss99](https://forum.codecrafters.io/u/rishilss99)\
**Post date:** [March 19, 2025, 1:53am UTC](https://forum.codecrafters.io/t/list-for-multiple-partitions-ku4/7116/1 "2025-03-19T01:53:09Z")

</div>

I am trying to parse the complete log file, but for some reason the last record batch seems to be out-of-place. I’ve considered Varints wherever mentioned as per the spec and my data for the first 4 Record batches seems to align. Based on the log, I see it has the following structure:

Record Batch 1:

- Feature Level Record

Record Batch 2:

- Topic Record
- Partition Record

Record Batch 3:

- Topic Record
- Partition Record

Record Batch 4:

- Topic Record
- Partition Record
- Partition Record

Since the test checks for a single topic with multiple partitions, I would be able to pass the test if I stopped parsing. But I am choosing to parse the log completely, I am not sure if the following RecordBatch 5 is being parsed as expected. Here’s the dump of the last RecordBatch 5 which seems to be incorrect to me but maybe that’s what is expected:

```auto
remote: [your_program] RecordBatch
remote: [your_program] Base Offset: 432345564227567616
remote: [your_program] Batch Length: -469762048
remote: [your_program] Partition Leader Epoch: 16777216
remote: [your_program] Magic Byte: 00000010
remote: [your_program] CRC: -607245691
remote: [your_program] Attributes: 0
remote: [your_program] Last Offset Delta: 33554432
remote: [your_program] Base Timestamp: 1525976868812029952
remote: [your_program] Max Timestamp: 1525976868812029952
remote: [your_program] Producer ID: -1
remote: [your_program] Producer Epoch: -1
remote: [your_program] Base Sequence: -1
remote: [your_program] Records Length: 50331648

```

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [March 19, 2025, 7:57am UTC](https://forum.codecrafters.io/t/list-for-multiple-partitions-ku4/7116/3 "2025-03-19T07:57:31Z")

</div>

Hey @rishilss99, could you [upload your code to GitHub](https://docs.codecrafters.io/features/publish-to-github) and share the link? It will be much easier to debug if I can run it directly.

---

<div class="post-metadata">

**Author:** ![rishilss99](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rishilss99/32/5137_2.png) [@rishilss99](https://forum.codecrafters.io/u/rishilss99)\
**Post date:** [March 19, 2025, 6:20pm UTC](https://forum.codecrafters.io/t/list-for-multiple-partitions-ku4/7116/4 "2025-03-19T18:20:29Z")

</div>

Hi @andy1li, appreciate the help. I’ve been stuck with this for quite a while now. Here’s the link [https://github.com/rishilss99/KafkaIO](https://github.com/rishilss99/KafkaIO) to my repository. I am printing the parsed records so hopefully things are easier for you to go through. It’s only the last Record Batch which seems to give me trouble, so I am sure the code is not entirely incorrect.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [March 20, 2025, 2:29pm UTC](https://forum.codecrafters.io/t/list-for-multiple-partitions-ku4/7116/6 "2025-03-20T14:29:09Z")

</div>

@rishilss99 There is no RecordBatch 5. I added these lines in `.codecrafters/run.sh` to dump the log file:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/9/9ed6a56caca86352a6346d64dc9c3790c0742fb4.png)

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/4/48174d0daa3598a1dac1f436f861bbc224537ab1.jpeg)

As you can see, there is no data after RecordBatch 4.

- Topic Record (length encoded as **0x3c** )
- Partition Record (length encoded as **0x9001** )
- Partition Record (length encoded as **0x9001** )

Let me know if you need further assistance!

---

<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 25, 2025, 2:30pm UTC](https://forum.codecrafters.io/t/list-for-multiple-partitions-ku4/7116/8 "2025-03-25T14:30:02Z")

</div>

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