Github user ppadma commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1072#discussion_r158032627
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SqlPatternContainsMatcher.java
 ---
    @@ -19,44 +19,283 @@
     
     import io.netty.buffer.DrillBuf;
     
    -public class SqlPatternContainsMatcher extends AbstractSqlPatternMatcher {
    +/** SQL Pattern Contains implementation */
    +public final class SqlPatternContainsMatcher extends 
AbstractSqlPatternMatcher {
    +  private final MatcherFcn matcherFcn;
     
       public SqlPatternContainsMatcher(String patternString) {
         super(patternString);
    +
    +    // Pattern matching is 1) a CPU intensive operation and 2) pattern and 
input dependent. The conclusion is
    +    // that there is no single implementation that can do it all well. So, 
we use multiple implementations
    +    // chosen based on the pattern length.
    +    if (patternLength == 1) {
    +      matcherFcn = new Matcher1();
    +    } else if (patternLength == 2) {
    +      matcherFcn = new Matcher2();
    +    } else if (patternLength == 3) {
    +      matcherFcn = new Matcher3();
    +    } else if (patternLength < 10) {
    +      matcherFcn = new MatcherN();
    +    } else {
    +      matcherFcn = new BoyerMooreMatcher();
    +    }
       }
     
       @Override
       public int match(int start, int end, DrillBuf drillBuf) {
    +    return matcherFcn.match(start, end, drillBuf);
    +  }
    +
    +  
//--------------------------------------------------------------------------
    +  // Inner Data Structure
    +  // 
--------------------------------------------------------------------------
    +
    +  /** Abstract matcher class to allow us pick the most efficient 
implementation */
    +  private abstract class MatcherFcn {
    +    protected final byte[] patternArray;
    +
    +    protected MatcherFcn() {
    +      assert patternByteBuffer.hasArray();
    --- End diff --
    
    is this true for null pattern ?


---

Reply via email to