lizhimins commented on code in PR #10930:
URL: https://github.com/apache/rocketmq/pull/10930#discussion_r3800628170


##########
broker/src/main/java/org/apache/rocketmq/broker/lite/LmqPrefixIndex.java:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.rocketmq.broker.lite;
+
+import java.util.SortedMap;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.function.Function;
+
+import org.apache.commons.collections4.trie.PatriciaTrie;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.common.lite.LiteUtil;
+
+/**
+ * Global prefix index over lmqName, backed by {@link PatriciaTrie}.
+ *
+ * <p>A single instance is shared across all parentTopics: every lmqName 
starts with
+ * {@link LiteUtil#LITE_TOPIC_PREFIX} followed by its parentTopic, so lmqs of 
the same
+ * parentTopic form a contiguous subtree, and a prefix lookup only walks that 
subtree.
+ *
+ * <p>Used to accelerate prefix-subscription full dispatch in
+ * {@link LiteEventDispatcher#doFullDispatchForClient(String, String)}.
+ *
+ * <p>A {@link ReadWriteLock} guards the trie; reads dominate writes by 
~10000x in steady state.
+ * Empty prefix / parentTopic is rejected to avoid an unintended full-table 
scan.
+ */
+public class LmqPrefixIndex {
+
+    private final PatriciaTrie<Boolean> trie = new PatriciaTrie<>();

Review Comment:
   高级啊



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