Cpaulyz commented on code in PR #7270:
URL: https://github.com/apache/iotdb/pull/7270#discussion_r972212614


##########
node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternTree.java:
##########
@@ -142,7 +141,7 @@ public List<String> getAllDevicePatterns() {
   }
 
   private void searchDevicePattern(
-      PathPatternNode curNode, List<String> nodes, Set<String> results) {
+      PathPatternNode<Void> curNode, List<String> nodes, Set<String> results) {

Review Comment:
   I didn't change the semantics of this interface. It originally seemed to 
assume that the device of `root.sg1.d1.**` is `root.sg1.d1.**`.  I didn't know 
if the modification will have an impact on the upper layer application
   



##########
node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternNode.java:
##########
@@ -26,46 +26,96 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.Supplier;
 
-public class PathPatternNode {
+import static 
org.apache.iotdb.commons.conf.IoTDBConstant.MULTI_LEVEL_PATH_WILDCARD;
+import static 
org.apache.iotdb.commons.conf.IoTDBConstant.ONE_LEVEL_PATH_WILDCARD;
+
+public class PathPatternNode<V> {
 
   private final String name;
-  private final Map<String, PathPatternNode> children;
+  private final Map<String, PathPatternNode<V>> children;
+  private Set<V> valueSet;

Review Comment:
   
   > It seems that you forgot about serializing this field.
   
   Nope. I reuse the data structure of the nodes in PathPatternTree here, 
mounting an additional valueSet. Serialization methods are only used in 
PathPatternTree, and the serialization information is used as a ByteBuffer in 
RPC. valueSet is always empty in PathPatternTree, so I did not serialize it to 
save network cost .
   
   
   > And equalsWIth may also take it into account
   
   I've added the valueSet comparison in `equalsWith`
   



##########
node-commons/src/main/java/org/apache/iotdb/commons/path/PatternTreeMap.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.iotdb.commons.path;
+
+import org.apache.iotdb.commons.conf.IoTDBConstant;
+
+import javax.annotation.concurrent.NotThreadSafe;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.Supplier;
+
+@NotThreadSafe
+public class PatternTreeMap<V> {
+  private final PathPatternNode<V> root;
+  private final Supplier<? extends Set<V>> supplier;
+  private BiConsumer<V, Set<V>> appendFunction;
+  private BiConsumer<V, Set<V>> deleteFunction;

Review Comment:
   done



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