You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by xu...@apache.org on 2015/09/09 09:09:06 UTC
[36/50] [abbrv] hive git commit: HIVE-11671 : Optimize RuleRegExp in
DPP codepath (Rajesh Balamohan, reviewed by Hari Subramaniyan)
HIVE-11671 : Optimize RuleRegExp in DPP codepath (Rajesh Balamohan, reviewed by Hari Subramaniyan)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/492c8b1d
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/492c8b1d
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/492c8b1d
Branch: refs/heads/beeline-cli
Commit: 492c8b1d88ffcb68ba4f77a3a49ae8fc768cdd7c
Parents: 1fc9320
Author: Hari Subramaniyan <ha...@apache.org>
Authored: Wed Sep 2 15:54:23 2015 -0700
Committer: Hari Subramaniyan <ha...@apache.org>
Committed: Wed Sep 2 15:54:23 2015 -0700
----------------------------------------------------------------------
.../apache/hadoop/hive/ql/lib/RuleRegExp.java | 22 +++++++++++---------
1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/492c8b1d/ql/src/java/org/apache/hadoop/hive/ql/lib/RuleRegExp.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/lib/RuleRegExp.java b/ql/src/java/org/apache/hadoop/hive/ql/lib/RuleRegExp.java
index c88ed68..fd5f133 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/lib/RuleRegExp.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/lib/RuleRegExp.java
@@ -125,13 +125,13 @@ public class RuleRegExp implements Rule {
*/
private int costPatternWithoutWildCardChar(Stack<Node> stack) throws SemanticException {
int numElems = (stack != null ? stack.size() : 0);
- String name = new String("");
int patLen = patternWithoutWildCardChar.length();
-
+ StringBuilder name = new StringBuilder(patLen + numElems);
for (int pos = numElems - 1; pos >= 0; pos--) {
- name = stack.get(pos).getName() + "%" + name;
+ String nodeName = stack.get(pos).getName() + "%";
+ name.insert(0, nodeName);
if (name.length() >= patLen) {
- if (patternWithoutWildCardChar.equals(name)) {
+ if (patternWithoutWildCardChar.contentEquals(name)) {
return patLen;
} else {
return -1;
@@ -153,13 +153,14 @@ public class RuleRegExp implements Rule {
private int costPatternWithORWildCardChar(Stack<Node> stack) throws SemanticException {
int numElems = (stack != null ? stack.size() : 0);
for (String pattern : patternORWildChar) {
- String name = new String("");
int patLen = pattern.length();
+ StringBuilder name = new StringBuilder(patLen + numElems);
for (int pos = numElems - 1; pos >= 0; pos--) {
- name = stack.get(pos).getName() + "%" + name;
+ String nodeName = stack.get(pos).getName() + "%";
+ name.insert(0, nodeName);
if (name.length() >= patLen) {
- if (pattern.equals(name)) {
+ if (pattern.contentEquals(name)) {
return patLen;
} else {
break;
@@ -181,11 +182,12 @@ public class RuleRegExp implements Rule {
* @throws SemanticException
*/
private int costPatternWithWildCardChar(Stack<Node> stack) throws SemanticException {
- int numElems = (stack != null ? stack.size() : 0);
- String name = "";
+ int numElems = (stack != null ? stack.size() : 0);
+ StringBuilder name = new StringBuilder();
Matcher m = patternWithWildCardChar.matcher("");
for (int pos = numElems - 1; pos >= 0; pos--) {
- name = stack.get(pos).getName() + "%" + name;
+ String nodeName = stack.get(pos).getName() + "%";
+ name.insert(0, nodeName);
m.reset(name);
if (m.matches()) {
return name.length();