kamalcph commented on code in PR #17659:
URL: https://github.com/apache/kafka/pull/17659#discussion_r1830355793


##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -1803,6 +1842,37 @@ Optional<RemoteLogSegmentMetadata> 
findNextSegmentMetadata(RemoteLogSegmentMetad
                 : Optional.empty();
     }
 
+    /**
+     * Returns the next segment that contains the aborted transaction entries. 
The search ensures that the returned
+     * segment offsets are greater than or equal to the given offset.
+     * @param tp The topic partition.
+     * @param offset The offset to start the search.
+     * @param fileCache The leader epoch file cache.
+     * @return The next segment that contains the transaction index.
+     * @throws RemoteStorageException If an error occurs while fetching the 
remote log segment metadata.
+     */
+    Optional<RemoteLogSegmentMetadata> 
findNextSegmentWithTxnIndex(TopicPartition tp,
+                                                                   long offset,
+                                                                   
LeaderEpochFileCache fileCache) throws RemoteStorageException {
+        Optional<RemoteLogSegmentMetadata> metadataOpt = Optional.empty();
+        if (fileCache != null) {
+            OptionalInt initialEpochOpt = fileCache.epochForOffset(offset);
+            if (initialEpochOpt.isPresent()) {
+                int initialEpoch = initialEpochOpt.getAsInt();
+                for (EpochEntry epochEntry : fileCache.epochEntries()) {

Review Comment:
   > maybeNextSegmentWithTrxIndex
   // returns empty when no segment metadata found with or w/o index
   // returns metadata with trxIndexEmpty either set to true or false when 
plugin doesn't have optimization
   // returns metadata with trxIndexEmpty either set to true when plugin has 
optimization
   
   These cases are handled, I've updated the Javadoc for 
RemoteLogManager#findNextSegmentWithTxnIndex to capture this.



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