apoorvmittal10 commented on code in PR #18514:
URL: https://github.com/apache/kafka/pull/18514#discussion_r1915595741


##########
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;
+                for (InFlightBatch currentStateBatch : cachedState.values()) {
+                    if (initialOffset != currentStateBatch.firstOffset()) {
+                        InFlightBatch newBatch = new 
InFlightBatch(EMPTY_MEMBER_ID, initialOffset, currentStateBatch.firstOffset() - 
1,
+                            RecordState.AVAILABLE, (short) 0, null);
+                        cachedState.put(initialOffset, newBatch);
+                    }
+                    initialOffset = currentStateBatch.lastOffset() + 1;
+                }

Review Comment:
   Can you move the processing to a method please.



##########
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;
+                for (InFlightBatch currentStateBatch : cachedState.values()) {
+                    if (initialOffset != currentStateBatch.firstOffset()) {
+                        InFlightBatch newBatch = new 
InFlightBatch(EMPTY_MEMBER_ID, initialOffset, currentStateBatch.firstOffset() - 
1,
+                            RecordState.AVAILABLE, (short) 0, null);
+                        cachedState.put(initialOffset, newBatch);
+                    }
+                    initialOffset = currentStateBatch.lastOffset() + 1;
+                }

Review Comment:
   nit: may be you want to execute it inside the if condition just below `if 
(!cachedState.isEmpty()) {`



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to