chia7712 commented on a change in pull request #10096:
URL: https://github.com/apache/kafka/pull/10096#discussion_r573463351



##########
File path: 
clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java
##########
@@ -2480,4 +2508,38 @@ String getClientId() {
     boolean updateAssignmentMetadataIfNeeded(final Timer timer) {
         return updateAssignmentMetadataIfNeeded(timer, true);
     }
+
+    /**
+     * Converts the fetched metadata to the public API 
ConsumerRecords.Metadata.
+     * Also computes overrides from left to the right in the case of multiple 
args.
+     * Any of the arg maps may be null, in which case, we just skip it.
+     */
+    @SafeVarargs
+    private static Map<TopicPartition, ConsumerRecords.Metadata> 
extractMetadata(final Map<TopicPartition, FetchedRecords.FetchMetadata>... 
nullableMetadataMaps) {
+        Map<TopicPartition, ConsumerRecords.Metadata> result = null;
+        for (Map<TopicPartition, FetchedRecords.FetchMetadata> 
nullableMetadataMap : nullableMetadataMaps) {
+            if (nullableMetadataMap == null || nullableMetadataMap.isEmpty()) {
+                continue;
+            } else {
+                if (result == null) {
+                    result = new HashMap<>(nullableMetadataMap.size());
+                }
+                for (Map.Entry<TopicPartition, FetchedRecords.FetchMetadata> 
entry : nullableMetadataMap.entrySet()) {
+                    result.put(
+                        entry.getKey(),
+                        new ConsumerRecords.Metadata(

Review comment:
       Not sure why we need to have `FetchedRecords.FetchMetadata`? It is 
always converted to `ConsumerRecords.Metadata` directly. The `records` in 
`FetchedRecords` is `ConsumerRecord`. Maybe we can make `FetchedRecords` use 
`ConsumerRecords.Metadata` also.




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

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


Reply via email to