MINOR: Improve Log layer segment iteration logic and few other areas#10684
MINOR: Improve Log layer segment iteration logic and few other areas#10684junrao merged 6 commits intoapache:trunkfrom
Conversation
010858d to
c1b293f
Compare
There was a problem hiding this comment.
@ijuma If you think this API is a good fit to the requirement, I can add unit tests for it.
|
cc @junrao |
There was a problem hiding this comment.
can we simply use while (fetchDataInfo == null && segmentOpt.isDefined) rather than while (!done)?
There was a problem hiding this comment.
Done. Please see 80c40171302546be2dcf2444167d7f375f0b820d.
|
LGTM Thanks @kowshik |
0134a4d to
4ffeaa3
Compare
There was a problem hiding this comment.
The old logic supports skipping forward multiple segments to find the right data. The new logic seems to only support skipping forward once. It would be useful to preserve the original semantic.
There was a problem hiding this comment.
That is an excellent catch. Sorry I missed this. Done, changed it now.
There was a problem hiding this comment.
Could we return a constant empty map?
e718bce to
4b83603
Compare
|
Thanks for the review @junrao! I have addressed your comments in 4b836034415c3d5f6b84384ef9be1e75b66edc4b. |
4b83603 to
4d86571
Compare
4d86571 to
7a84aa1
Compare
|
@junrao Thanks for the review and for catching this issue! I've fixed the build now. The issue was that the code in I have now also added unit tests for the newly introduced The PR is ready for review again. |
Log.collectAbortedTransactions()I've restored a previously used logic, such that it would handle the case where the starting segment could be null. This was the case previously, but the PR KAFKA-12552: Introduce LogSegments class abstracting the segments map #10401 accidentally changed the behavior causing the code to assume that the starting segment won't be null.Log.rebuildProducerState()I've removed usage of theallSegmentslocal variable. The logic looks a bit simpler after I removed it.LogSegments.higherSegments()API. This is now used to make the logic a bit more readable inLog. collectAbortedTransactions()andLog.deletableSegments()APIs.java.lang.LonginLogSegmentsclass' segments map definition.LogSegmentsAPI from public to private, as they need not be public.Tests:
Relying on existing unit tests.