lhotari commented on code in PR #25921:
URL: https://github.com/apache/pulsar/pull/25921#discussion_r3350429878


##########
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/TopicMessageId.java:
##########
@@ -41,6 +41,19 @@ public interface TopicMessageId extends MessageId {
      */
     String getOwnerTopic();
 
+    /**
+     * Checks if this message's owner topic and the given topic refer to the 
same base
+     * partitioned topic by comparing their base partitioned topic names.
+     *
+     * <p>For example, {@code 
persistent://public/default/my-topic-partition-0} matches
+     * {@code persistent://public/default/my-topic} or any other partition of 
that topic.
+     * Topics sharing only a name prefix (e.g., {@code my-topic} vs {@code 
my-topic-v2}) do not match.
+     *
+     * @param topicName a full topic name (non-partitioned, partitioned, or 
specific partition)
+     * @return {@code true} if both topics resolve to the same base 
partitioned topic name
+     */
+    boolean hasSameBasePartitionedTopic(String topicName);

Review Comment:
   add the current implementation in `TopicMessageIdImpl` as the default 
implementation of this method.



##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/TopicMessageIdImpl.java:
##########
@@ -92,6 +93,12 @@ public String getOwnerTopic() {
         return ownerTopic;
     }
 
+    @Override
+    public boolean hasSameBasePartitionedTopic(String topicName) {
+        return TopicName.get(getOwnerTopic()).getPartitionedTopicName()
+                .equals(TopicName.get(topicName).getPartitionedTopicName());
+    }

Review Comment:
   move to TopicMessageId as the default implementation



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

Reply via email to