You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/03/09 08:40:17 UTC

[GitHub] [iotdb] MarcosZyk commented on a change in pull request #5110: [IOTDB-2598]Enable append operation on template after setting and using

MarcosZyk commented on a change in pull request #5110:
URL: https://github.com/apache/iotdb/pull/5110#discussion_r822405792



##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTree.java
##########
@@ -1718,105 +1758,96 @@ public int getMountedNodeIndexOnMeasurementPath(PartialPath measurementPath)
     return fullPathNodes.length - 1;
   }
 
-  public List<String> getPathsSetOnTemplate(String templateName) throws MetadataException {
+  public List<String> getPathsSetOnTemplate(Template template) throws MetadataException {
+    String templateName = template == null ? "" : template.getName();
+    Set<PartialPath> initPath =
+        template == null
+            ? Collections.singleton(new PartialPath("root"))
+            : template.getRelatedStorageGroup();
     List<String> resSet = new ArrayList<>();
-    CollectorTraverser<Set<String>> setTemplatePaths =
-        new CollectorTraverser<Set<String>>(
-            root, root.getPartialPath().concatNode(MULTI_LEVEL_PATH_WILDCARD)) {
-          @Override
-          protected boolean processInternalMatchedMNode(IMNode node, int idx, int level)
-              throws MetadataException {
-            // will never get here, implement for placeholder
-            return false;
-          }
-
-          @Override
-          protected boolean processFullMatchedMNode(IMNode node, int idx, int level)
-              throws MetadataException {
-            // shall not traverse nodes inside template
-            if (!node.getPartialPath().equals(getCurrentPartialPath(node))) {
-              return true;
+    for (PartialPath sgPath : initPath) {
+      CollectorTraverser<Set<String>> setTemplatePaths =
+          new CollectorTraverser<Set<String>>(
+              this.root, sgPath.concatNode(MULTI_LEVEL_PATH_WILDCARD)) {
+            @Override
+            protected boolean processInternalMatchedMNode(IMNode node, int idx, int level)
+                throws MetadataException {
+              // will never get here, implement for placeholder
+              return false;
             }
 
-            // if node not set template, go on traversing
-            if (node.getUpperTemplate() != null) {
-              // if set template, and equals to target or target for all, add to result
-              if (templateName.equals("")
-                  || templateName.equals(node.getUpperTemplate().getName())) {
-                resSet.add(node.getFullPath());
+            @Override
+            protected boolean processFullMatchedMNode(IMNode node, int idx, int level)
+                throws MetadataException {
+              // shall not traverse nodes inside template
+              if (!node.getPartialPath().equals(getCurrentPartialPath(node))) {
+                return true;
+              }
+
+              // if node not set template, go on traversing
+              if (node.getSchemaTemplate() != null) {
+                // if set template, and equals to target or target for all, add to result
+                if (templateName.equals("")
+                    || templateName.equals(node.getUpperTemplate().getName())) {
+                  resSet.add(node.getFullPath());
+                }
+                // descendants of the node cannot set another template, exit from this branch
+                return true;
               }
-              // descendants of the node cannot set another template, exit from this branch
-              return true;
+              return false;
             }
-            return false;
-          }
-        };
-    setTemplatePaths.traverse();
+          };
+      setTemplatePaths.traverse();
+    }
     return resSet;
   }
 
-  public List<String> getPathsUsingTemplate(String templateName) throws MetadataException {
+  public List<String> getPathsUsingTemplate(Template template) throws MetadataException {
+    String templateName = template == null ? "" : template.getName();

Review comment:
       Should we use * ?

##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTree.java
##########
@@ -1718,105 +1758,96 @@ public int getMountedNodeIndexOnMeasurementPath(PartialPath measurementPath)
     return fullPathNodes.length - 1;
   }
 
-  public List<String> getPathsSetOnTemplate(String templateName) throws MetadataException {
+  public List<String> getPathsSetOnTemplate(Template template) throws MetadataException {
+    String templateName = template == null ? "" : template.getName();

Review comment:
       Should this template name "" replaced by * ? I see * means all template.




-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org