[
https://issues.apache.org/jira/browse/DRILL-5697?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16133514#comment-16133514
]
ASF GitHub Bot commented on DRILL-5697:
---------------------------------------
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/907#discussion_r134035089
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/RegexpUtil.java
---
@@ -96,20 +145,46 @@ public static String sqlToRegexLike(
|| (nextChar == '%')
|| (nextChar == escapeChar)) {
javaPattern.append(nextChar);
+ simplePattern.append(nextChar);
i++;
} else {
throw invalidEscapeSequence(sqlPattern, i);
}
} else if (c == '_') {
+ // if we find _, it is not simple pattern, we are looking for only
%
+ notSimple = true;
javaPattern.append('.');
} else if (c == '%') {
+ if (i == 0) {
+ // % at the start could potentially be one of the simple cases
i.e. ENDS_WITH.
+ endsWith = true;
+ } else if (i == (len-1)) {
+ // % at the end could potentially be one of the simple cases
i.e. STARTS_WITH
+ startsWith = true;
+ } else {
+ // If we find % anywhere other than start or end, it is not a
simple case.
+ notSimple = true;
+ }
javaPattern.append(".");
javaPattern.append('*');
} else {
javaPattern.append(c);
+ simplePattern.append(c);
}
}
- return javaPattern.toString();
+
+ if (!notSimple) {
--- End diff --
Yeah, the zillion-flags approach is too complex to follow. Really need a
good-old state machine.
> Improve performance of filter operator for pattern matching
> -----------------------------------------------------------
>
> Key: DRILL-5697
> URL: https://issues.apache.org/jira/browse/DRILL-5697
> Project: Apache Drill
> Issue Type: Improvement
> Components: Execution - Flow
> Affects Versions: 1.11.0
> Reporter: Padma Penumarthy
> Assignee: Padma Penumarthy
>
> Queries using filter with sql like operator use Java regex library for
> pattern matching. However, for cases like %abc (ends with abc), abc% (starts
> with abc), %abc% (contains abc), it is observed that implementing these cases
> with simple code instead of using regex library provides good performance
> boost (4-6x). Idea is to use special case code for simple, common cases and
> fall back to Java regex library for complicated ones. That will provide good
> performance benefit for most common cases.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)