oikon48 commented on code in PR #16632:
URL: https://github.com/apache/iotdb/pull/16632#discussion_r3328319895


##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/pattern/TreePattern.java:
##########
@@ -75,9 +121,165 @@ public static TreePattern 
parsePipePatternFromSourceParameters(
     final boolean isTreeModelDataAllowedToBeCaptured =
         isTreeModelDataAllowToBeCaptured(sourceParameters);
 
-    final String path = sourceParameters.getStringByKeys(EXTRACTOR_PATH_KEY, 
SOURCE_PATH_KEY);
-    final String pattern =
-        sourceParameters.getStringByKeys(EXTRACTOR_PATTERN_KEY, 
SOURCE_PATTERN_KEY);
+    // 1. Define the default inclusion pattern (matches all, "root.**")
+    // This is used if no inclusion patterns are specified.
+    final TreePattern defaultInclusionPattern =
+        buildUnionPattern(
+            isTreeModelDataAllowedToBeCaptured,
+            Collections.singletonList(
+                new IoTDBTreePattern(isTreeModelDataAllowedToBeCaptured, 
null)));
+
+    // 2. Parse INCLUSION patterns using the helper
+    final TreePattern inclusionPattern =
+        parsePatternUnion(
+            sourceParameters,
+            isTreeModelDataAllowedToBeCaptured,
+            // 'path' keys (IoTDB wildcard)
+            EXTRACTOR_PATH_KEY,
+            SOURCE_PATH_KEY,
+            // 'pattern' keys (Prefix or IoTDB via format)
+            EXTRACTOR_PATTERN_KEY,
+            SOURCE_PATTERN_KEY,
+            // Default pattern if no keys are found
+            defaultInclusionPattern);
+
+    // 3. Parse EXCLUSION patterns using the helper
+    final TreePattern exclusionPattern =
+        parsePatternUnion(
+            sourceParameters,
+            isTreeModelDataAllowedToBeCaptured,
+            // 'path.exclusion' keys (IoTDB wildcard)
+            EXTRACTOR_PATH_EXCLUSION_KEY,
+            SOURCE_PATH_EXCLUSION_KEY,
+            // 'pattern.exclusion' keys (Prefix)
+            EXTRACTOR_PATTERN_EXCLUSION_KEY,
+            SOURCE_PATTERN_EXCLUSION_KEY,
+            // Default for exclusion is "match nothing" (null)
+            null);
+
+    // 4. Combine inclusion and exclusion
+    if (exclusionPattern == null) {
+      // No exclusion defined, return the inclusion pattern directly
+      return inclusionPattern;
+    } else {
+      // If both inclusion and exclusion patterns support IoTDB operations,
+      // use the specialized ExclusionIoTDBTreePattern
+      if (inclusionPattern instanceof IoTDBPatternOperations
+          && exclusionPattern instanceof IoTDBPatternOperations) {
+        return new ExclusionIoTDBTreePattern(
+            isTreeModelDataAllowedToBeCaptured,
+            (IoTDBPatternOperations) inclusionPattern,
+            (IoTDBPatternOperations) exclusionPattern);
+      }
+      // Both are defined, wrap them in an ExclusionTreePattern
+      return new ExclusionTreePattern(
+          isTreeModelDataAllowedToBeCaptured, inclusionPattern, 
exclusionPattern);
+    }
+  }
+
+  /**
+   * The main entry point for parsing a pattern string. This method can handle 
simple patterns
+   * ("root.a"), union patterns ("root.a,root.b"), and exclusion patterns 
("INCLUSION(root.a),
+   * EXCLUSION(root.b)").
+   */
+  public static TreePattern parsePatternFromString(
+      final String patternString,
+      final boolean isTreeModelDataAllowedToBeCaptured,
+      final Function<String, TreePattern> basePatternSupplier) {

Review Comment:
   Duplicate of the resolved thread above; addressed in the commit noted there.



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