MINOR: Remove usage of Stream API in CoordinatorRecordHelpers (#15969)

This patch removes the usage of the Stream API in CoordinatorRecordHelpers. I saw it in a couple of profiles so it is better to remove it.

Reviewers: Justine Olshan <jolshan@confluent.io>, Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
David Jacot 2024-05-16 08:13:55 +02:00 committed by GitHub
parent ba19eedb90
commit ffb31e172a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 6 deletions

View File

@ -46,7 +46,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* This class contains helper methods to create records stored in
@ -231,6 +230,17 @@ public class CoordinatorRecordHelpers {
String memberId,
Map<Uuid, Set<Integer>> partitions
) {
List<ConsumerGroupTargetAssignmentMemberValue.TopicPartition> topicPartitions =
new ArrayList<>(partitions.size());
for (Map.Entry<Uuid, Set<Integer>> entry : partitions.entrySet()) {
topicPartitions.add(
new ConsumerGroupTargetAssignmentMemberValue.TopicPartition()
.setTopicId(entry.getKey())
.setPartitions(new ArrayList<>(entry.getValue()))
);
}
return new CoordinatorRecord(
new ApiMessageAndVersion(
new ConsumerGroupTargetAssignmentMemberKey()
@ -240,11 +250,7 @@ public class CoordinatorRecordHelpers {
),
new ApiMessageAndVersion(
new ConsumerGroupTargetAssignmentMemberValue()
.setTopicPartitions(partitions.entrySet().stream()
.map(keyValue -> new ConsumerGroupTargetAssignmentMemberValue.TopicPartition()
.setTopicId(keyValue.getKey())
.setPartitions(new ArrayList<>(keyValue.getValue())))
.collect(Collectors.toList())),
.setTopicPartitions(topicPartitions),
(short) 0
)
);