You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/11/25 16:22:07 UTC

[iotdb] branch opti_path_check created (now ed62459735)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a change to branch opti_path_check
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at ed62459735 Skip checking duplicated measurements in one write request

This branch includes the following new commits:

     new ed62459735 Skip checking duplicated measurements in one write request

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: Skip checking duplicated measurements in one write request

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch opti_path_check
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit ed62459735af42444bf9bc457a7c0508130bad9d
Author: HTHou <hh...@outlook.com>
AuthorDate: Sat Nov 26 00:21:33 2022 +0800

    Skip checking duplicated measurements in one write request
---
 .../org/apache/iotdb/commons/utils/PathUtils.java  | 39 +++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/utils/PathUtils.java b/node-commons/src/main/java/org/apache/iotdb/commons/utils/PathUtils.java
index 658df351ef..3837424864 100644
--- a/node-commons/src/main/java/org/apache/iotdb/commons/utils/PathUtils.java
+++ b/node-commons/src/main/java/org/apache/iotdb/commons/utils/PathUtils.java
@@ -26,7 +26,9 @@ import org.apache.iotdb.tsfile.exception.PathParseException;
 import org.apache.iotdb.tsfile.read.common.parser.PathNodesGenerator;
 import org.apache.iotdb.tsfile.read.common.parser.PathVisitor;
 
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 public class PathUtils {
 
@@ -63,8 +65,43 @@ public class PathUtils {
     if (measurementLists == null) {
       return;
     }
+    // use set to skip checking duplicated measurements
+    Set<String> measurementSet = new HashSet<>();
     for (List<String> measurements : measurementLists) {
-      isLegalSingleMeasurements(measurements);
+      checkLegalSingleMeasurementsAndSkipDuplicate(measurements, measurementSet);
+    }
+  }
+
+  /**
+   * check whether measurement is legal according to syntax convention measurement can only be a
+   * single node name, use set to skip checking duplicated measurements
+   */
+  public static void checkLegalSingleMeasurementsAndSkipDuplicate(
+      List<String> measurements, Set<String> measurementSet) throws MetadataException {
+    if (measurements == null) {
+      return;
+    }
+    for (String measurement : measurements) {
+      if (measurement == null) {
+        continue;
+      }
+      if (measurementSet.contains(measurement)) {
+        continue;
+      }
+      measurementSet.add(measurement);
+      if (measurement.startsWith(TsFileConstant.BACK_QUOTE_STRING)
+          && measurement.endsWith(TsFileConstant.BACK_QUOTE_STRING)) {
+        if (checkBackQuotes(measurement.substring(1, measurement.length() - 1))) {
+          continue;
+        } else {
+          throw new IllegalPathException(measurement);
+        }
+      }
+      if (IoTDBConstant.reservedWords.contains(measurement.toUpperCase())
+          || isRealNumber(measurement)
+          || !TsFileConstant.NODE_NAME_PATTERN.matcher(measurement).matches()) {
+        throw new IllegalPathException(measurement);
+      }
     }
   }