MINOR: refactor FetchResponse#toMessage to avoid creating a lot of un…#9818
Conversation
|
Thanks for the PR. Have you checked that we get the same batching this way? The behavior won't be the same unless the iterator order is correct. |
|
@ijuma Thanks for your quick response!
There is a test to verify the batch order (https://github.com/apache/kafka/blob/trunk/core/src/test/scala/unit/kafka/server/FetchRequestTest.scala#L83).
There are two rules of batching partition data.
It seems to me the reason of generating the intermediate collections before is that reusing the data in |
ijuma
left a comment
There was a problem hiding this comment.
On closer inspection, I now remember that batchByTopic already relies on the ordering, so the new implementation is equivalent. LGTM overall. A nit below that should be easy to resolve.
There was a problem hiding this comment.
Maybe we could have a variable called previousTopic to make this code more readable.
There was a problem hiding this comment.
Nice suggestion. will address it later.
Instead of creating intermediate collections to batch data, we directly check the last topic in auto-generated data to collect partitions having same topic.
Committer Checklist (excluded from commit message)