ryukobayashi commented on code in PR #4998:
URL: https://github.com/apache/hive/pull/4998#discussion_r1535262366


##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/FilterStringColLikeStringScalar.java:
##########
@@ -58,12 +56,11 @@ protected List<CheckerFactory> getCheckerFactories() {
    * Accepts simple LIKE patterns like "abc%" and creates corresponding 
checkers.
    */
   private static class BeginCheckerFactory implements CheckerFactory {
-    private static final Pattern BEGIN_PATTERN = Pattern.compile("([^_%]+)%");
-
     public Checker tryCreate(String pattern) {
-      Matcher matcher = BEGIN_PATTERN.matcher(pattern);
-      if (matcher.matches()) {
-        return new BeginChecker(matcher.group(1));
+      CheckerPattern checkerPattern = new 
CheckerPattern(UDFLike.PatternType.BEGIN, pattern);
+      String matche = checkerPattern.check();

Review Comment:
   OK, that's how I fixed it.



##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/FilterStringColLikeStringScalar.java:
##########
@@ -140,4 +133,84 @@ public Checker tryCreate(String pattern) {
       return new ComplexChecker("^" + UDFLike.likePatternToRegExp(pattern) + 
"$");
     }
   }
+
+  /**
+   * Check the LIKE pattern..
+   */
+  private static class CheckerPattern {
+    private final String pattern;
+    private final UDFLike.PatternType type;
+
+    public CheckerPattern(UDFLike.PatternType type, String pattern) {
+      this.type = type;
+      this.pattern = pattern;
+    }
+
+    public String check() {
+      UDFLike.PatternType lastType = UDFLike.PatternType.NONE;
+      int length = pattern.length();
+      int beginIndex = 0;
+      int endIndex = length;
+      char lastChar = 0;
+      String strPattern = new String();
+      String simplePattern;
+
+      for (int i = 0; i < length; i++) {

Review Comment:
   @deniskuzZ  This was originally a bug in `java.util.regex`, so it was a fix 
to use `com.google.re2j` instead of using regex as is. The comments below led 
me to implement a custom algorithm: 
https://github.com/apache/hive/pull/3117#issuecomment-1076183992
   
   So, I don't have any particular attachment to custom algorithms. Which is 
better?



##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/FilterStringColLikeStringScalar.java:
##########
@@ -140,4 +133,84 @@ public Checker tryCreate(String pattern) {
       return new ComplexChecker("^" + UDFLike.likePatternToRegExp(pattern) + 
"$");
     }
   }
+
+  /**
+   * Check the LIKE pattern..
+   */
+  private static class CheckerPattern {
+    private final String pattern;
+    private final UDFLike.PatternType type;
+
+    public CheckerPattern(UDFLike.PatternType type, String pattern) {
+      this.type = type;
+      this.pattern = pattern;
+    }
+
+    public String check() {
+      UDFLike.PatternType lastType = UDFLike.PatternType.NONE;
+      int length = pattern.length();
+      int beginIndex = 0;
+      int endIndex = length;
+      char lastChar = 0;
+      String strPattern = new String();

Review Comment:
   Fixed.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to