Github user ppadma commented on a diff in the pull request:
https://github.com/apache/drill/pull/1001#discussion_r146392275
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SqlPatternContainsMatcher.java
---
@@ -17,37 +17,166 @@
*/
package org.apache.drill.exec.expr.fn.impl;
-public class SqlPatternContainsMatcher implements SqlPatternMatcher {
+public final class SqlPatternContainsMatcher implements SqlPatternMatcher {
final String patternString;
CharSequence charSequenceWrapper;
final int patternLength;
+ final MatcherFcn matcherFcn;
public SqlPatternContainsMatcher(String patternString, CharSequence
charSequenceWrapper) {
- this.patternString = patternString;
+ this.patternString = patternString;
this.charSequenceWrapper = charSequenceWrapper;
- patternLength = patternString.length();
+ patternLength = patternString.length();
+
+ // The idea is to write loops with simple condition checks to allow
the Java Hotspot achieve
+ // better optimizations (especially vectorization)
+ if (patternLength == 1) {
+ matcherFcn = new Matcher1();
--- End diff --
I am not sure if it is a good idea to write special case code for each
pattern length. It is not easy to maintain. Can you please give more details
how this is improving performance ? Are we getting better performance for
patternLength 1 or 2 or 3 or N or all ? If so, how much and why ?
---