JimmyWang6 commented on code in PR #20246:
URL: https://github.com/apache/kafka/pull/20246#discussion_r2367213804


##########
core/src/main/java/kafka/server/share/SharePartition.java:
##########
@@ -2311,6 +2316,24 @@ long findLastOffsetAcknowledged() {
         return lastOffsetAcknowledged;
     }
 
+    /**
+     * Find the maximum offset from the first batch within the request offset 
for {@link ShareAcquireMode.STRICT} mode.
+     *
+     * @param batches The batches to search for the request offset.
+     * @param offset The request offset to find.
+     * @return The minimum value between the first batch's last offset and the 
request offset.
+     *         If no batches are available, returns the original request 
offset.
+     */
+    private long maxOffsetFromFirstBatch(
+        Iterable<? extends RecordBatch> batches,
+        long offset
+    ) {
+        for (RecordBatch batch : batches) {
+            return Math.min(batch.lastOffset(), offset);
+        }
+        return offset;
+    }

Review Comment:
   I have changed the code structure and polished the comments, please take 
another look.



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

Reply via email to