List for multiple partitions #ku4

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:

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

Hey @rishilss99, could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.

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 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.

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

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!

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