VGalaxies commented on code in PR #16789:
URL: https://github.com/apache/iotdb/pull/16789#discussion_r2609358841
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/pattern/TreePattern.java:
##########
@@ -140,60 +140,72 @@ public static TreePattern
parsePipePatternFromSourceParameters(
final boolean isTreeModelDataAllowedToBeCaptured =
isTreeModelDataAllowToBeCaptured(sourceParameters);
- // 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(
+ // 1. Parse INCLUSION patterns into a list
+ List<TreePattern> inclusionPatterns =
+ parsePatternList(
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);
+ SOURCE_PATTERN_KEY);
+
+ // If no inclusion patterns are specified, use default "root.**"
+ if (inclusionPatterns.isEmpty()) {
+ inclusionPatterns =
+ new ArrayList<>(
+ Collections.singletonList(
+ new IoTDBTreePattern(isTreeModelDataAllowedToBeCaptured,
null)));
+ }
- // 3. Parse EXCLUSION patterns using the helper
- final TreePattern exclusionPattern =
- parsePatternUnion(
+ // 2. Parse EXCLUSION patterns into a list
+ List<TreePattern> exclusionPatterns =
+ parsePatternList(
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 IoTDBTreePatternOperations
- && exclusionPattern instanceof IoTDBTreePatternOperations) {
- return new WithExclusionIoTDBTreePattern(
- isTreeModelDataAllowedToBeCaptured,
- (IoTDBTreePatternOperations) inclusionPattern,
- (IoTDBTreePatternOperations) exclusionPattern);
- }
- // Both are defined, wrap them in an ExclusionTreePattern
- return new WithExclusionTreePattern(
- isTreeModelDataAllowedToBeCaptured, inclusionPattern,
exclusionPattern);
+ SOURCE_PATTERN_EXCLUSION_KEY);
+
+ // 3. Optimize the lists: remove redundant patterns (e.g., if "root.**"
exists, "root.db" is
+ // redundant)
+ inclusionPatterns = optimizePatterns(inclusionPatterns);
+ exclusionPatterns = optimizePatterns(exclusionPatterns);
+
+ // 4. Prune inclusion patterns: if an inclusion pattern is fully covered
by an exclusion
+ // pattern, remove it
+ inclusionPatterns = pruneInclusionPatterns(inclusionPatterns,
exclusionPatterns);
Review Comment:
removed
--
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]