You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by mi...@apache.org on 2026/09/09 11:58:29 UTC
(kafka) branch trunk updated: MINOR: remove redundant stream round-trip in MirrorSourceConnector (#23403)
This is an automated email from the ASF dual-hosted git repository.
mimaison pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 6bafed66563 MINOR: remove redundant stream round-trip in MirrorSourceConnector (#23403)
6bafed66563 is described below
commit 6bafed6656303c7cd23c0eb7695b674306824fa4
Author: OuO <ma...@outlook.com>
AuthorDate: Wed Sep 9 19:58:21 2026 +0800
MINOR: remove redundant stream round-trip in MirrorSourceConnector (#23403)
`computeAndCreateTopicPartitions` collected the partition counts with
`Collectors.groupingBy(..., counting())` and then immediately streamed
the resulting entry set back into `Collectors.toMap(Entry::getKey,
Entry::getValue)`. That second pass rebuilds an identical map, so it is
pure overhead.
This removes the redundant round-trip for both
`sourceTopicToPartitionCounts` and `targetTopicToPartitionCounts`.
Reviewers: Mickael Maison <mi...@gmail.com>
---
.../java/org/apache/kafka/connect/mirror/MirrorSourceConnector.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorSourceConnector.java b/connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorSourceConnector.java
index 8eb5a929440..b0ef2834820 100644
--- a/connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorSourceConnector.java
+++ b/connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorSourceConnector.java
@@ -455,11 +455,9 @@ public class MirrorSourceConnector extends SourceConnector {
void computeAndCreateTopicPartitions() throws ExecutionException, InterruptedException {
// get source and target topics with respective partition counts
Map<String, Long> sourceTopicToPartitionCounts = knownSourceTopicPartitions.stream()
- .collect(Collectors.groupingBy(TopicPartition::topic, Collectors.counting())).entrySet().stream()
- .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+ .collect(Collectors.groupingBy(TopicPartition::topic, Collectors.counting()));
Map<String, Long> targetTopicToPartitionCounts = knownTargetTopicPartitions.stream()
- .collect(Collectors.groupingBy(TopicPartition::topic, Collectors.counting())).entrySet().stream()
- .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+ .collect(Collectors.groupingBy(TopicPartition::topic, Collectors.counting()));
Set<String> knownSourceTopics = sourceTopicToPartitionCounts.keySet();
Set<String> knownTargetTopics = targetTopicToPartitionCounts.keySet();