AshinGau commented on code in PR #10213:
URL: https://github.com/apache/doris/pull/10213#discussion_r900045154


##########
fe/fe-core/src/main/java/org/apache/doris/common/PatternMatcher.java:
##########
@@ -20,27 +20,58 @@
 import com.google.common.base.Strings;
 import com.google.common.collect.Sets;
 
+import java.util.Locale;
 import java.util.Set;
 import java.util.regex.Pattern;
 
 // Wrap for Java pattern and matcher
 public class PatternMatcher {
+    public static PatternMatcher MATCH_ANY = new 
PatternMatcher(Pattern.compile(".*"));
     private Pattern pattern;
+    private String casePattern;
+    private boolean caseSensitive;
 
     private static final Set<Character> FORBIDDEN_CHARS = Sets.newHashSet('<', 
'(', '[', '{', '^', '=',
                                                                           '$', 
'!', '|', ']', '}', ')',
                                                                           '?', 
'*', '+', '>', '@');
 
+    public PatternMatcher(Pattern pattern) {
+        this.pattern = pattern;
+    }
+
+    public PatternMatcher(String casePattern, boolean caseSensitive) {
+        this.casePattern = caseSensitive ? casePattern : 
casePattern.toLowerCase(Locale.ROOT);
+        this.caseSensitive = caseSensitive;
+    }
+
     public boolean match(String candidate) {
-        if (pattern == null || candidate == null) {
-            // No pattern, how can I explain this? Return false now.
-            // No candidate, return false.
+        if (candidate == null) {
             return false;
         }
-        if (pattern.matcher(candidate).matches()) {
-            return true;
+        if (pattern != null) {
+            return pattern.matcher(candidate).matches();
+        }
+        if (caseSensitive) {
+            return candidate.equals(casePattern);
+        } else {
+            return candidate.toLowerCase(Locale.ROOT).equals(casePattern);

Review Comment:
   when initialize PatternMatcher, casePattern is lowercase if caseSensitive = 
false



-- 
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: commits-unsubscr...@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to