Hangleton commented on code in PR #13240:
URL: https://github.com/apache/kafka/pull/13240#discussion_r1129167871


##########
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 agree with you and am not satisfied either with `TopicResolver` but could 
not find a better name. `TopicIdResolver` would be misleading because this 
class treats topic ids and names symmetrically. One of the closest entity with 
similar purposes as this is in 
[`MetadataCache#L93`](https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/server/MetadataCache.scala#L93)
 where `topicIdInfo` is used to refer to the bidirectional mapping. The suffix 
`Info` could be used here as well although it is not strictly aligned with 
other uses of that suffix such as in 
[`TopicPartitionInfo`](https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/TopicPartitionInfo.java).
  Interestingly another entity for which may have had to be assigned a generic 
name is 
[`TopicCollection`](https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/TopicCollection.java).
   
   Using another name to refer to the dual name/id reference such as 
`TopicRefResolver` introduces yet another noun (_reference_) not used elsewhere 
in the codebase and which can be confusing.
   
   So, I am not sure about what could be a better name but maybe 
`TopicInfoResolver` or `TopicIdInfoResolver` or `TopicIdInfo` or 
`TopicIdResolver` may sound better albeit still ambiguous and partially 
incorrect?



-- 
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

Reply via email to