dajac commented on code in PR #15970: URL: https://github.com/apache/kafka/pull/15970#discussion_r1608552211
########## group-coordinator/src/test/java/org/apache/kafka/coordinator/group/assignor/GeneralUniformAssignmentBuilderTest.java: ########## @@ -45,12 +48,20 @@ public class GeneralUniformAssignmentBuilderTest { private final Uuid topic4Uuid = Uuid.fromString("T4-Tw9fVTLCz5HbPp6YQsa"); private final String topic1Name = "topic1"; private final String topic2Name = "topic2"; - private final String topic3Name = "topic3"; +private final String topic3Name = "topic3"; Review Comment: nit: Indentation is off. ########## group-coordinator/src/test/java/org/apache/kafka/coordinator/group/assignor/OptimizedUniformAssignmentBuilderTest.java: ########## @@ -133,13 +144,13 @@ public void testFirstAssignmentTwoMembersTwoTopicsNoMemberRacks() { members.put(memberA, new AssignmentMemberSpec( Optional.empty(), Optional.empty(), - Arrays.asList(topic1Uuid, topic3Uuid), + new TopicIds(mkSet(topic1Name, topic3Name), topicsImage), Review Comment: Same question. ########## group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/TopicIds.java: ########## @@ -0,0 +1,185 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kafka.coordinator.group.consumer; + +import org.apache.kafka.common.Uuid; +import org.apache.kafka.image.TopicImage; +import org.apache.kafka.image.TopicsImage; + +import java.util.Collection; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +/** + * TopicIds is initialized with topic names (String) but exposes a Set of topic ids (Uuid) to the + * user and performs the conversion lazily with TopicsImage. + */ +public class TopicIds implements Set<Uuid> { Review Comment: Should we add unit tests for this class? ########## group-coordinator/src/test/java/org/apache/kafka/coordinator/group/assignor/GeneralUniformAssignmentBuilderTest.java: ########## @@ -103,13 +114,13 @@ public void testTwoMembersSubscribedToNonexistentTopics() { members.put(memberA, new AssignmentMemberSpec( Optional.empty(), Optional.empty(), - Collections.singletonList(topic3Uuid), + new TopicIds(Collections.singleton(topic3Name), topicsImage), Review Comment: Why do we need this change? It looks like the previous version would just work, no? ########## group-coordinator/src/test/java/org/apache/kafka/coordinator/group/assignor/RangeAssignorTest.java: ########## @@ -99,7 +108,7 @@ public void testOneConsumerSubscribedToNonExistentTopic() { new AssignmentMemberSpec( Optional.empty(), Optional.empty(), - Collections.singletonList(topic2Uuid), + new TopicIds(Collections.singleton(topic2Name), topicsImage), Review Comment: Same question. ########## jmh-benchmarks/src/main/java/org/apache/kafka/jmh/assignor/ServerSideAssignorBenchmark.java: ########## @@ -119,7 +123,13 @@ public enum AssignmentType { private SubscribedTopicDescriber subscribedTopicDescriber; - private final List<Uuid> allTopicIds = new ArrayList<>(); + private final List<String> allTopicNames = new ArrayList<>(); + + private ImmutableMap<Uuid, TopicImage> topicsById = ImmutableMap.empty(); + + private ImmutableMap<String, TopicImage> topicsByName = ImmutableMap.empty(); + + private TopicsImage topicsImage = TopicsImage.EMPTY; Review Comment: Hum... I guess that we cannot. In this case, it may be better to build the image the right way. We usually build it like we do in the MetadataImageBuilder. ########## group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/TopicIds.java: ########## @@ -0,0 +1,185 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kafka.coordinator.group.consumer; + +import org.apache.kafka.common.Uuid; +import org.apache.kafka.image.TopicImage; +import org.apache.kafka.image.TopicsImage; + +import java.util.Collection; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +/** + * TopicIds is initialized with topic names (String) but exposes a Set of topic ids (Uuid) to the + * user and performs the conversion lazily with TopicsImage. + */ +public class TopicIds implements Set<Uuid> { + private final Set<String> topicNames; + private final TopicsImage image; + + public TopicIds( + Set<String> topicNames, + TopicsImage image + ) { + this.topicNames = topicNames; + this.image = image; Review Comment: nit: Should we require non-null here too? -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org