You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2020/02/12 06:54:35 UTC
[spark] branch branch-3.0 updated: Revert "[SPARK-30245][SQL] Add
cache for Like and RLike when pattern is not static"
This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 6e1b6cc Revert "[SPARK-30245][SQL] Add cache for Like and RLike when pattern is not static"
6e1b6cc is described below
commit 6e1b6cc5c55c4d945f59da68d248cc3ef82569d3
Author: HyukjinKwon <gu...@apache.org>
AuthorDate: Mon Feb 10 10:56:43 2020 -0800
Revert "[SPARK-30245][SQL] Add cache for Like and RLike when pattern is not static"
### What changes were proposed in this pull request?
This reverts commit 8ce7962931680c204e84dd75783b1c943ea9c525. There's variable name conflicts with https://github.com/apache/spark/commit/8aebc80e0e67bcb1aa300b8c8b1a209159237632#diff-39298b470865a4cbc67398a4ea11e767.
This can be cleanly ported back to branch-3.0.
### Why are the changes needed?
Performance investigation were not made enough and it's not clear if it really beneficial or now.
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Jenkins tests.
Closes #27514 from HyukjinKwon/revert-cache-PR.
Authored-by: HyukjinKwon <gu...@apache.org>
Signed-off-by: Xiao Li <ga...@gmail.com>
---
.../catalyst/expressions/regexpExpressions.scala | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala
index c9ddc70..f84c476 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala
@@ -177,6 +177,8 @@ case class Like(str: Expression, pattern: Expression, escape: Expression)
""")
}
} else {
+ val patternStr = ctx.freshName("patternStr")
+ val compiledPattern = ctx.freshName("compiledPattern")
// We need double escape to avoid org.codehaus.commons.compiler.CompileException.
// '\\' will cause exception 'Single quote must be backslash-escaped in character literal'.
// '\"' will cause exception 'Line break in literal not allowed'.
@@ -185,17 +187,11 @@ case class Like(str: Expression, pattern: Expression, escape: Expression)
} else {
escapeChar
}
- val patternStr = ctx.freshName("patternStr")
- val compiledPattern = ctx.addMutableState(patternClass, "compiledPattern")
- val lastPatternStr = ctx.addMutableState(classOf[String].getName, "lastPatternStr")
-
nullSafeCodeGen(ctx, ev, (eval1, eval2, _) => {
s"""
String $patternStr = $eval2.toString();
- if (!$patternStr.equals($lastPatternStr)) {
- $compiledPattern = $patternClass.compile($escapeFunc($patternStr, '$newEscapeChar'));
- $lastPatternStr = $patternStr;
- }
+ $patternClass $compiledPattern = $patternClass.compile(
+ $escapeFunc($patternStr, '$newEscapeChar'));
${ev.value} = $compiledPattern.matcher($eval1.toString()).matches();
"""
})
@@ -278,16 +274,11 @@ case class RLike(left: Expression, right: Expression)
}
} else {
val rightStr = ctx.freshName("rightStr")
- val pattern = ctx.addMutableState(patternClass, "pattern")
- val lastRightStr = ctx.addMutableState(classOf[String].getName, "lastRightStr")
-
+ val pattern = ctx.freshName("pattern")
nullSafeCodeGen(ctx, ev, (eval1, eval2) => {
s"""
String $rightStr = $eval2.toString();
- if (!$rightStr.equals($lastRightStr)) {
- $pattern = $patternClass.compile($rightStr);
- $lastRightStr = $rightStr;
- }
+ $patternClass $pattern = $patternClass.compile($rightStr);
${ev.value} = $pattern.matcher($eval1.toString()).find(0);
"""
})
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org