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


##########
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:
   can we transform CheckerPattern to enum and use it like
   ````
   UDFLikePattern.BEGIN.check(pattern)
   ````
   also, you might move the `Checker` impl into the enum constructor and 
initialize it dynamically.
   ````
     private enum UDFLikePattern {
       BEGIN(BeginChecker.class);
       Class<? extends Checker> checker;
   
       UDFLikePattern(Class<? extends Checker> checker) {
         this.checker = checker;
       }
   
       public Checker check(String pattern) {
         String matche = ...
         if (matche != null) { 
           try {
             return checker.getConstructor(String.class).newInstance(pattern);
           } catch (Exception e) {
             throw new IllegalArgumentException("unable to initialize Checker");
           }
         }
       }
     }
   ````



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