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


##########
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:
   (thinking some more about interface design)
   
   should we push this down to the concrete implementation? Asking because all 
RLMM implementations may not have a way to figure out nextSegmentWithTrxIndex 
directly. An implementation may decide to loop over segments Instead but to do 
that they will leader leaderEpochCache which is not necessarily available in 
the plugin.
   
   Proposed change:
   
   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



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