smjn commented on code in PR #18514:
URL: https://github.com/apache/kafka/pull/18514#discussion_r1914830900
##########
core/src/main/java/kafka/server/share/SharePartition.java:
##########
@@ -456,6 +456,17 @@ public CompletableFuture<Void> maybeInitialize() {
stateBatch.lastOffset(),
RecordState.forId(stateBatch.deliveryState()), stateBatch.deliveryCount(),
null);
cachedState.put(stateBatch.firstOffset(), inFlightBatch);
}
+
+ long initialOffset = startOffset;
Review Comment:
This might work
```
soFar = startOffset
// assuming non-overlapping, sorted batches by first, last, deliveryCount,
deliveryState
for(Batch b: batches) {
// case 1:
// | <--- start offset
// ------- <--- interval // gap between start offset
and interval
if soFar < b.firstOffset()
Batch newBatch = new Batch(soFar, b.firstOffset()-1, 0, 0)
cache.put(soFar, newBatch)
// case 2:
// | // firstOffset intersection (No new batch)
// --------
else
cache.put(soFar, batch)
// case 3:
// | // intersection somewhere in the middle (not
possible due to persister)
// --------
// case 4:
// | // intersection at last offset (not possible due to
persister)
// --------
// case 5:
// | // interval lastOffset < startOffset (not possible due
to persister)
// ------
soFar = batch.lastOffset() + 1
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]