chia7712 commented on code in PR #23710:
URL: https://github.com/apache/kafka/pull/23710#discussion_r4183465086
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/TopicIds.java:
##########
@@ -122,12 +122,30 @@ public final CoordinatorMetadataImage image() {
@Override
public String name(Uuid id) {
- return topicNames.computeIfAbsent(id, __ ->
image.topicMetadata(id).map(CoordinatorMetadataImage.TopicMetadata::name).orElse(null));
+ // Uses get and put rather than computeIfAbsent, whose lambda
would capture the id and
Review Comment:
I guess the performance won't be as good as the cache layer, since
`HashTreePMap` is slower than `HashMap` on `get`. However, I presume the
simpler code is worth it 😆
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/TopicIds.java:
##########
@@ -122,12 +122,30 @@ public final CoordinatorMetadataImage image() {
@Override
public String name(Uuid id) {
- return topicNames.computeIfAbsent(id, __ ->
image.topicMetadata(id).map(CoordinatorMetadataImage.TopicMetadata::name).orElse(null));
+ // Uses get and put rather than computeIfAbsent, whose lambda
would capture the id and
Review Comment:
Have we considered adding a lightweight method to get either the id or the
name from the image directly, without going through this cache layer?
```java
@Override
public Uuid topicId(String name) {
TopicImage topic = metadataImage.topics().getTopic(name);
return topic == null ? null : topic.id();
}
@Override
public String topicName(Uuid id) {
TopicImage topic = metadataImage.topics().getTopic(id);
return topic == null ? null : topic.name();
}
```
--
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]