BewareMyPower commented on code in PR #24463: URL: https://github.com/apache/pulsar/pull/24463#discussion_r2230192986
########## pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java: ########## @@ -111,64 +110,70 @@ public static String getPattern(String topic) { return "^" + Pattern.quote(get(topic).getPartitionedTopicName().toString()) + "$"; } + /** + * The constructor from a topic name string. The difference from {@link TopicName#get(String)} is that the `get` + * method can leverage the built-in cache mechanism, which can be slightly faster, but at the cost of higher JVM + * memory usage that could lead to unnecessary GC, as well as potentially OOM in extreme cases. + * You can benchmark `TopicName.get(topic)` and `new TopicName(topic)` to see the actual performance gap. + * + * @param completeTopicName the topic name + */ @SuppressFBWarnings("DCN_NULLPOINTER_EXCEPTION") - private TopicName(String completeTopicName) { + public TopicName(String completeTopicName) { Review Comment: No. It's not just used in the benchmark. The downstream (e.g. the protocol handler) application can maintain its own cache mechanism for `TopicName` once the constructor is public. -- 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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org