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


##########
core/src/main/java/kafka/server/share/DelayedShareFetch.java:
##########
@@ -204,6 +187,58 @@ Map<TopicIdPartition, FetchRequest.PartitionData> 
acquirablePartitions() {
         return topicPartitionData;
     }
 
+    /**
+     * Prepare partitions fetch data structure for acquirable partitions in 
the share fetch request satisfying minBytes criteria.
+     */
+    Map<TopicIdPartition, FetchPartitionData> 
replicaManagerFetchData(Map<TopicIdPartition, FetchRequest.PartitionData> 
topicPartitionData,
+                                                                      boolean 
hasRequestTimedOut) {
+        log.trace("Fetchable share partitions data: {} with groupId: {} fetch 
params: {}", topicPartitionData,
+            shareFetchData.groupId(), shareFetchData.fetchParams());
+        Map<TopicIdPartition, FetchPartitionData> 
replicaManagerFetchSatisfyingMinBytes = new HashMap<>();
+        Map<TopicIdPartition, FetchPartitionData> responseData = new 
HashMap<>();
+        try {
+            Seq<Tuple2<TopicIdPartition, LogReadResult>> responseLogResult = 
replicaManager.readFromLog(
+                shareFetchData.fetchParams(),
+                CollectionConverters.asScala(
+                    topicPartitionData.entrySet().stream().map(entry ->
+                        new Tuple2<>(entry.getKey(), 
entry.getValue())).collect(Collectors.toList())
+                ),
+                QuotaFactory.UnboundedQuota$.MODULE$,
+                true);
+
+            AtomicInteger accumulatedBytes = new AtomicInteger(0);
+
+            responseLogResult.foreach(tpLogResult -> {
+                TopicIdPartition topicIdPartition = tpLogResult._1();
+                LogReadResult logResult = tpLogResult._2();
+                FetchPartitionData fetchPartitionData = 
logResult.toFetchPartitionData(false);
+                responseData.put(topicIdPartition, fetchPartitionData);
+                
accumulatedBytes.addAndGet(logResult.info().records.sizeInBytes());

Review Comment:
   I think you are right. I also see only reference of param minBytes in 
fetchMessages and not in readFromLog. Also the readFromLog says upto maximum in 
description and nothing about minBytes.
   
   Then the PR change sounds good but I was wondering why do we accept complete 
fetchParams in readFromLog when we don't utilize something like minBytes there. 
Not sure if we should have minBytes support in readFromLog itself. Maybe out of 
scope of this PR.
   
   @junrao can help is with more context.



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