Hangleton commented on code in PR #13240: URL: https://github.com/apache/kafka/pull/13240#discussion_r1129272424
########## clients/src/main/java/org/apache/kafka/common/TopicResolver.java: ########## @@ -0,0 +1,92 @@ +/* + * 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.common; + +import org.apache.kafka.common.errors.InvalidTopicException; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +/** + * Encapsulates the resolution of a topic name from its ID, or its ID from its name, using a local + * bidirectional mapping. This resolver assumes there is a bijection between topic IDs and topic names. + * <p></p> + * Note that this class intends to be used for the (reverse) lookup of topic IDs/names, but + * not to characterize the set of topics which are known by a client. Use the + * {@link org.apache.kafka.clients.MetadataCache} for that purpose. + */ +//@Immutable, @ThreadSafe +public class TopicResolver { Review Comment: I would tend to have a preference for a business type which conveys semantics versus a generic data structure, but that is not very important here especially since the entity exposing the bidirectional mapping is relatively short-lived when used in the code. One advantage of a generic DS is that it can be reused for other purposes. Another thing is that there is no functionality provided outside that of a bimap and since no extension is foreseen, there is no need to expose a specialized type. Very happy to expose it as a bimap. I could not find an existing implementation in the codebase or its dependencies, although there is a bidirectional multimap defined within restricted scope [here](https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/admin/internals/AdminApiDriver.java#L459-L489). -- 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