Repository: hive
Updated Branches:
  refs/heads/master 290ff1f5a -> c7e1d34b6


HIVE-11406: Vectorization: StringExpr::compare() == 0 is bad for performance 
(Matt McCline, reviewed by Gopal V)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/c7e1d34b
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/c7e1d34b
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/c7e1d34b

Branch: refs/heads/master
Commit: c7e1d34b6e8734ca65e9a635f4094876b2032d77
Parents: 290ff1f
Author: Matt McCline <mmccl...@hortonworks.com>
Authored: Tue Aug 4 11:01:12 2015 -0700
Committer: Matt McCline <mmccl...@hortonworks.com>
Committed: Tue Aug 4 11:01:12 2015 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hive/ant/GenVectorCode.java   | 103 +++++++++++++++++
 ...tringGroupColumnCompareStringGroupColumn.txt | 112 +++++++++----------
 ...gGroupColumnCompareStringGroupScalarBase.txt |  12 +-
 ...gGroupScalarCompareStringGroupColumnBase.txt |  12 +-
 ...tringGroupColumnCompareStringGroupColumn.txt | 112 +++++++++----------
 ...gGroupColumnCompareStringGroupScalarBase.txt |  12 +-
 ...gGroupScalarCompareStringGroupColumnBase.txt |  12 +-
 .../ql/exec/vector/expressions/StringExpr.java  |  24 ++++
 8 files changed, 263 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/c7e1d34b/ant/src/org/apache/hadoop/hive/ant/GenVectorCode.java
----------------------------------------------------------------------
diff --git a/ant/src/org/apache/hadoop/hive/ant/GenVectorCode.java 
b/ant/src/org/apache/hadoop/hive/ant/GenVectorCode.java
index 6485a2a..54f3783 100644
--- a/ant/src/org/apache/hadoop/hive/ant/GenVectorCode.java
+++ b/ant/src/org/apache/hadoop/hive/ant/GenVectorCode.java
@@ -1338,6 +1338,23 @@ public class GenVectorCode extends Task {
     File templateFile = new File(joinPath(this.expressionTemplateDirectory, 
tdesc[0] + ".txt"));
     String templateString = readFile(templateFile);
     // Expand, and write result
+
+    String compareOrEqual;
+    String compareOrEqualReturnType = "boolean";
+    String optionalCompare = "";
+    if (operatorName.equals("Equal")) {
+      compareOrEqual = "StringExpr.equal";
+    } else if (operatorName.equals("NotEqual")) {
+      compareOrEqual = "!StringExpr.equal";
+    } else {
+      compareOrEqual = "StringExpr.compare";
+      compareOrEqualReturnType = "int";
+      optionalCompare = operatorSymbol + " 0";
+    }
+    templateString = templateString.replaceAll("<CompareOrEqual>", 
compareOrEqual);
+    templateString = templateString.replaceAll("<CompareOrEqualReturnType>", 
compareOrEqualReturnType);
+    templateString = templateString.replaceAll("<OptionalCompare>", 
optionalCompare);
+
     templateString = templateString.replaceAll("<ClassName>", className);
     templateString = templateString.replaceAll("<BaseClassName>", 
baseClassName);
     templateString = templateString.replaceAll("<OperatorSymbol>", 
operatorSymbol);
@@ -1370,6 +1387,23 @@ public class GenVectorCode extends Task {
     File templateFile = new File(joinPath(this.expressionTemplateDirectory, 
tdesc[0] + ".txt"));
     String templateString = readFile(templateFile);
     // Expand, and write result
+
+    String compareOrEqual;
+    String compareOrEqualReturnType = "boolean";
+    String optionalCompare = "";
+    if (operatorName.equals("Equal")) {
+      compareOrEqual = "StringExpr.equal";
+    } else if (operatorName.equals("NotEqual")) {
+      compareOrEqual = "!StringExpr.equal";
+    } else {
+      compareOrEqual = "StringExpr.compare";
+      compareOrEqualReturnType = "int";
+      optionalCompare = operatorSymbol + " 0";
+    }
+    templateString = templateString.replaceAll("<CompareOrEqual>", 
compareOrEqual);
+    templateString = templateString.replaceAll("<CompareOrEqualReturnType>", 
compareOrEqualReturnType);
+    templateString = templateString.replaceAll("<OptionalCompare>", 
optionalCompare);
+
     templateString = templateString.replaceAll("<ClassName>", className);
     templateString = templateString.replaceAll("<BaseClassName>", 
baseClassName);
     templateString = templateString.replaceAll("<OperatorSymbol>", 
operatorSymbol);
@@ -1399,6 +1433,23 @@ public class GenVectorCode extends Task {
     File templateFile = new File(joinPath(this.expressionTemplateDirectory, 
tdesc[0] + ".txt"));
     String templateString = readFile(templateFile);
     // Expand, and write result
+
+    String compareOrEqual;
+    String compareOrEqualReturnType = "boolean";
+    String optionalCompare = "";
+    if (operatorName.equals("Equal")) {
+      compareOrEqual = "StringExpr.equal";
+    } else if (operatorName.equals("NotEqual")) {
+      compareOrEqual = "!StringExpr.equal";
+    } else {
+      compareOrEqual = "StringExpr.compare";
+      compareOrEqualReturnType = "int";
+      optionalCompare = operatorSymbol + " 0";
+    }
+    templateString = templateString.replaceAll("<CompareOrEqual>", 
compareOrEqual);
+    templateString = templateString.replaceAll("<CompareOrEqualReturnType>", 
compareOrEqualReturnType);
+    templateString = templateString.replaceAll("<OptionalCompare>", 
optionalCompare);
+
     templateString = templateString.replaceAll("<ClassName>", className);
     templateString = templateString.replaceAll("<BaseClassName>", 
baseClassName);
     templateString = templateString.replaceAll("<OperatorSymbol>", 
operatorSymbol);
@@ -1422,6 +1473,23 @@ public class GenVectorCode extends Task {
     File templateFile = new File(joinPath(this.expressionTemplateDirectory, 
tdesc[0] + ".txt"));
     String templateString = readFile(templateFile);
     // Expand, and write result
+
+    String compareOrEqual;
+    String compareOrEqualReturnType = "boolean";
+    String optionalCompare = "";
+    if (operatorName.equals("Equal")) {
+      compareOrEqual = "StringExpr.equal";
+    } else if (operatorName.equals("NotEqual")) {
+      compareOrEqual = "!StringExpr.equal";
+    } else {
+      compareOrEqual = "StringExpr.compare";
+      compareOrEqualReturnType = "int";
+      optionalCompare = operatorSymbol + " 0";
+    }
+    templateString = templateString.replaceAll("<CompareOrEqual>", 
compareOrEqual);
+    templateString = templateString.replaceAll("<CompareOrEqualReturnType>", 
compareOrEqualReturnType);
+    templateString = templateString.replaceAll("<OptionalCompare>", 
optionalCompare);
+
     templateString = templateString.replaceAll("<ClassName>", className);
     templateString = templateString.replaceAll("<OperatorSymbol>", 
operatorSymbol);
     writeFile(templateFile.lastModified(), expressionOutputDirectory, 
expressionClassesDirectory,
@@ -1437,6 +1505,23 @@ public class GenVectorCode extends Task {
     File templateFile = new File(joinPath(this.expressionTemplateDirectory, 
tdesc[0] + ".txt"));
     String templateString = readFile(templateFile);
     // Expand, and write result
+
+    String compareOrEqual;
+    String compareOrEqualReturnType = "boolean";
+    String optionalCompare = "";
+    if (operatorName.equals("Equal")) {
+      compareOrEqual = "StringExpr.equal";
+    } else if (operatorName.equals("NotEqual")) {
+      compareOrEqual = "!StringExpr.equal";
+    } else {
+      compareOrEqual = "StringExpr.compare";
+      compareOrEqualReturnType = "int";
+      optionalCompare = operatorSymbol + " 0";
+    }
+    templateString = templateString.replaceAll("<CompareOrEqual>", 
compareOrEqual);
+    templateString = templateString.replaceAll("<CompareOrEqualReturnType>", 
compareOrEqualReturnType);
+    templateString = templateString.replaceAll("<OptionalCompare>", 
optionalCompare);
+
     templateString = templateString.replaceAll("<ClassName>", className);
     templateString = templateString.replaceAll("<BaseClassName>", 
baseClassName);
     templateString = templateString.replaceAll("<OperatorSymbol>", 
operatorSymbol);
@@ -1466,11 +1551,29 @@ public class GenVectorCode extends Task {
 
   private void generateStringColumnCompareScalar(String[] tdesc, String 
className)
       throws IOException {
+    String operatorName = tdesc[1];
     String operatorSymbol = tdesc[2];
     // Read the template into a string;
     File templateFile = new File(joinPath(this.expressionTemplateDirectory, 
tdesc[0] + ".txt"));
     String templateString = readFile(templateFile);
     // Expand, and write result
+
+    String compareOrEqual;
+    String compareOrEqualReturnType = "boolean";
+    String optionalCompare = "";
+    if (operatorName.equals("Equal")) {
+      compareOrEqual = "StringExpr.equal";
+    } else if (operatorName.equals("NotEqual")) {
+      compareOrEqual = "!StringExpr.equal";
+    } else {
+      compareOrEqual = "StringExpr.compare";
+      compareOrEqualReturnType = "int";
+      optionalCompare = operatorSymbol + " 0";
+    }
+    templateString = templateString.replaceAll("<CompareOrEqual>", 
compareOrEqual);
+    templateString = templateString.replaceAll("<CompareOrEqualReturnType>", 
compareOrEqualReturnType);
+    templateString = templateString.replaceAll("<OptionalCompare>", 
optionalCompare);
+
     templateString = templateString.replaceAll("<ClassName>", className);
     templateString = templateString.replaceAll("<OperatorSymbol>", 
operatorSymbol);
     writeFile(templateFile.lastModified(), expressionOutputDirectory, 
expressionClassesDirectory,

http://git-wip-us.apache.org/repos/asf/hive/blob/c7e1d34b/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupColumnCompareStringGroupColumn.txt
----------------------------------------------------------------------
diff --git 
a/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupColumnCompareStringGroupColumn.txt
 
b/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupColumnCompareStringGroupColumn.txt
index 70fce17..a72b882 100644
--- 
a/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupColumnCompareStringGroupColumn.txt
+++ 
b/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupColumnCompareStringGroupColumn.txt
@@ -75,8 +75,8 @@ public class <ClassName> extends VectorExpression {
         /* Either all must remain selected or all will be eliminated.
          * Repeating property will not change.
          */
-        if (!(StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                 vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0)) {
+        if (!(<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                 vector2[0], start2[0], 
length2[0])<OptionalCompare>)) {
           batch.size = 0;
         }      
       } else if (inputColVector1.isRepeating) {
@@ -84,8 +84,8 @@ public class <ClassName> extends VectorExpression {
           int newSize = 0;
           for(int j = 0; j != n; j++) {
             int i = sel[j];
-            if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                   vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                   vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
               sel[newSize++] = i;
             }
           }
@@ -93,8 +93,8 @@ public class <ClassName> extends VectorExpression {
         } else {
           int newSize = 0;
           for(int i = 0; i != n; i++) {
-            if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                   vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                   vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
               sel[newSize++] = i;
             }
           }
@@ -108,8 +108,8 @@ public class <ClassName> extends VectorExpression {
           int newSize = 0;
           for(int j = 0; j != n; j++) {
             int i = sel[j];
-            if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                   vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                   vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
               sel[newSize++] = i;
             }
           }
@@ -117,8 +117,8 @@ public class <ClassName> extends VectorExpression {
         } else {
           int newSize = 0;
           for(int i = 0; i != n; i++) {
-            if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                   vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                   vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
               sel[newSize++] = i;
             }
           }
@@ -131,8 +131,8 @@ public class <ClassName> extends VectorExpression {
         int newSize = 0;
         for(int j = 0; j != n; j++) {
           int i = sel[j];
-          if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                 vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                 vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
             sel[newSize++] = i;
           }
         }
@@ -140,8 +140,8 @@ public class <ClassName> extends VectorExpression {
       } else {
         int newSize = 0;
         for(int i = 0; i != n; i++) {
-          if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                 vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                 vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
             sel[newSize++] = i;
           }
         }
@@ -155,8 +155,8 @@ public class <ClassName> extends VectorExpression {
     } else if (inputColVector1.noNulls) { 
       if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
         if (nullPos2[0] ||
-            !(StringExpr.compare(vector1[0], start1[0], length1[0], 
-                               vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0)) {
+            !(<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                               vector2[0], start2[0], 
length2[0])<OptionalCompare>)) {
           batch.size = 0; 
         } 
       } else if (inputColVector1.isRepeating) {
@@ -167,8 +167,8 @@ public class <ClassName> extends VectorExpression {
           for(int j = 0; j != n; j++) {
             int i = sel[j];
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -178,8 +178,8 @@ public class <ClassName> extends VectorExpression {
           int newSize = 0;
           for(int i = 0; i != n; i++) {
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -200,8 +200,8 @@ public class <ClassName> extends VectorExpression {
           int newSize = 0;
           for(int j = 0; j != n; j++) {
             int i = sel[j];
-            if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                   vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                   vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
               sel[newSize++] = i;
             }
           }
@@ -209,8 +209,8 @@ public class <ClassName> extends VectorExpression {
         } else {
           int newSize = 0;
           for(int i = 0; i != n; i++) {
-            if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                   vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                   vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
               sel[newSize++] = i;
             }
           }
@@ -225,8 +225,8 @@ public class <ClassName> extends VectorExpression {
           for(int j = 0; j != n; j++) {
             int i = sel[j];
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -236,8 +236,8 @@ public class <ClassName> extends VectorExpression {
           int newSize = 0;
           for(int i = 0; i != n; i++) {
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -253,8 +253,8 @@ public class <ClassName> extends VectorExpression {
     } else if (inputColVector2.noNulls) {
       if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
         if (nullPos1[0] ||
-            !(StringExpr.compare(vector1[0], start1[0], length1[0], 
-                               vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0)) {
+            !(<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                               vector2[0], start2[0], 
length2[0])<OptionalCompare>)) {
           batch.size = 0; 
           return;
         } 
@@ -269,8 +269,8 @@ public class <ClassName> extends VectorExpression {
           int newSize = 0;
           for(int j = 0; j != n; j++) {
             int i = sel[j];
-            if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                   vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                   vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
               sel[newSize++] = i;
             }
           }
@@ -278,8 +278,8 @@ public class <ClassName> extends VectorExpression {
         } else {
           int newSize = 0;
           for(int i = 0; i != n; i++) {
-            if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                   vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                   vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
               sel[newSize++] = i;
             }
           }
@@ -294,8 +294,8 @@ public class <ClassName> extends VectorExpression {
           for(int j = 0; j != n; j++) {
             int i = sel[j];
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -305,8 +305,8 @@ public class <ClassName> extends VectorExpression {
           int newSize = 0;
           for(int i = 0; i != n; i++) {
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -322,8 +322,8 @@ public class <ClassName> extends VectorExpression {
           for(int j = 0; j != n; j++) {
             int i = sel[j];
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -333,8 +333,8 @@ public class <ClassName> extends VectorExpression {
           int newSize = 0;
           for(int i = 0; i != n; i++) {
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -350,8 +350,8 @@ public class <ClassName> extends VectorExpression {
     } else {
       if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
         if (nullPos1[0] || nullPos2[0] ||
-            !(StringExpr.compare(vector1[0], start1[0], length1[0], 
-                               vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0)) {
+            !(<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                               vector2[0], start2[0], 
length2[0])<OptionalCompare>)) {
           batch.size = 0; 
         } 
       } else if (inputColVector1.isRepeating) {
@@ -364,8 +364,8 @@ public class <ClassName> extends VectorExpression {
           for(int j = 0; j != n; j++) {
             int i = sel[j];
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -375,8 +375,8 @@ public class <ClassName> extends VectorExpression {
           int newSize = 0;
           for(int i = 0; i != n; i++) {
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -396,8 +396,8 @@ public class <ClassName> extends VectorExpression {
           for(int j = 0; j != n; j++) {
             int i = sel[j];
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -407,8 +407,8 @@ public class <ClassName> extends VectorExpression {
           int newSize = 0;
           for(int i = 0; i != n; i++) {
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -424,8 +424,8 @@ public class <ClassName> extends VectorExpression {
           for(int j = 0; j != n; j++) {
             int i = sel[j];
             if (!nullPos1[i] && !nullPos2[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }
@@ -435,8 +435,8 @@ public class <ClassName> extends VectorExpression {
           int newSize = 0;
           for(int i = 0; i != n; i++) {
             if (!nullPos1[i] && !nullPos2[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 sel[newSize++] = i;
               }
             }

http://git-wip-us.apache.org/repos/asf/hive/blob/c7e1d34b/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupColumnCompareStringGroupScalarBase.txt
----------------------------------------------------------------------
diff --git 
a/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupColumnCompareStringGroupScalarBase.txt
 
b/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupColumnCompareStringGroupScalarBase.txt
index 1c868ba..8b1c366 100644
--- 
a/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupColumnCompareStringGroupScalarBase.txt
+++ 
b/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupColumnCompareStringGroupScalarBase.txt
@@ -57,7 +57,7 @@ public abstract class <ClassName> extends VectorExpression {
       if (inputColVector.isRepeating) {
       
         // All must be selected otherwise size would be zero. Repeating 
property will not change.
-        if (!(StringExpr.compare(vector[0], start[0], length[0], value, 0, 
value.length) <OperatorSymbol> 0)) {
+        if (!(<CompareOrEqual>(vector[0], start[0], length[0], value, 0, 
value.length)<OptionalCompare>)) {
 
           //Entire batch is filtered out.
           batch.size = 0;
@@ -66,7 +66,7 @@ public abstract class <ClassName> extends VectorExpression {
         int newSize = 0;
         for(int j=0; j != n; j++) {
           int i = sel[j];
-          if (StringExpr.compare(vector[i], start[i], length[i], value, 0, 
value.length) <OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector[i], start[i], length[i], value, 0, 
value.length)<OptionalCompare>) {
             sel[newSize++] = i;
           }
         }
@@ -74,7 +74,7 @@ public abstract class <ClassName> extends VectorExpression {
       } else {
         int newSize = 0;
         for(int i = 0; i != n; i++) {
-          if (StringExpr.compare(vector[i], start[i], length[i], value, 0, 
value.length) <OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector[i], start[i], length[i], value, 0, 
value.length)<OptionalCompare>) {
             sel[newSize++] = i;
           }
         }
@@ -88,7 +88,7 @@ public abstract class <ClassName> extends VectorExpression {
       
         // All must be selected otherwise size would be zero. Repeating 
property will not change.
         if (!nullPos[0]) {
-          if (!(StringExpr.compare(vector[0], start[0], length[0], value, 0, 
value.length) <OperatorSymbol> 0)) {
+          if (!(<CompareOrEqual>(vector[0], start[0], length[0], value, 0, 
value.length)<OptionalCompare>)) {
 
             //Entire batch is filtered out.
             batch.size = 0;
@@ -101,7 +101,7 @@ public abstract class <ClassName> extends VectorExpression {
         for(int j=0; j != n; j++) {
           int i = sel[j];
           if (!nullPos[i]) {
-           if (StringExpr.compare(vector[i], start[i], length[i], value, 0, 
value.length) <OperatorSymbol> 0) {
+           if (<CompareOrEqual>(vector[i], start[i], length[i], value, 0, 
value.length)<OptionalCompare>) {
              sel[newSize++] = i;
            }
           }
@@ -113,7 +113,7 @@ public abstract class <ClassName> extends VectorExpression {
         int newSize = 0;
         for(int i = 0; i != n; i++) {
           if (!nullPos[i]) {
-            if (StringExpr.compare(vector[i], start[i], length[i], value, 0, 
value.length) <OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector[i], start[i], length[i], value, 0, 
value.length)<OptionalCompare>) {
               sel[newSize++] = i;
             }
           }

http://git-wip-us.apache.org/repos/asf/hive/blob/c7e1d34b/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupScalarCompareStringGroupColumnBase.txt
----------------------------------------------------------------------
diff --git 
a/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupScalarCompareStringGroupColumnBase.txt
 
b/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupScalarCompareStringGroupColumnBase.txt
index 91f5909..930069c 100644
--- 
a/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupScalarCompareStringGroupColumnBase.txt
+++ 
b/ql/src/gen/vectorization/ExpressionTemplates/FilterStringGroupScalarCompareStringGroupColumnBase.txt
@@ -61,7 +61,7 @@ public abstract class <ClassName> extends VectorExpression {
       if (inputColVector.isRepeating) {
       
         // All must be selected otherwise size would be zero. Repeating 
property will not change.
-        if (!(StringExpr.compare(value, 0, value.length, vector[0], start[0], 
length[0]) <OperatorSymbol> 0)) {
+        if (!(<CompareOrEqual>(value, 0, value.length, vector[0], start[0], 
length[0])<OptionalCompare>)) {
 
           //Entire batch is filtered out.
           batch.size = 0;
@@ -70,7 +70,7 @@ public abstract class <ClassName> extends VectorExpression {
         int newSize = 0;
         for(int j=0; j != n; j++) {
           int i = sel[j];
-          if (StringExpr.compare(value, 0, value.length, vector[i], start[i], 
length[i]) <OperatorSymbol> 0) {
+          if (<CompareOrEqual>(value, 0, value.length, vector[i], start[i], 
length[i])<OptionalCompare>) {
             sel[newSize++] = i;
           }
         }
@@ -78,7 +78,7 @@ public abstract class <ClassName> extends VectorExpression {
       } else {
         int newSize = 0;
         for(int i = 0; i != n; i++) {
-          if (StringExpr.compare(value, 0, value.length, vector[i], start[i], 
length[i]) <OperatorSymbol> 0) {
+          if (<CompareOrEqual>(value, 0, value.length, vector[i], start[i], 
length[i])<OptionalCompare>) {
             sel[newSize++] = i;
           }
         }
@@ -92,7 +92,7 @@ public abstract class <ClassName> extends VectorExpression {
       
         // All must be selected otherwise size would be zero. Repeating 
property will not change.
         if (!nullPos[0]) {
-          if (!(StringExpr.compare(value, 0, value.length, vector[0], 
start[0], length[0]) <OperatorSymbol> 0)) {
+          if (!(<CompareOrEqual>(value, 0, value.length, vector[0], start[0], 
length[0])<OptionalCompare>)) {
 
             //Entire batch is filtered out.
             batch.size = 0;
@@ -105,7 +105,7 @@ public abstract class <ClassName> extends VectorExpression {
         for(int j=0; j != n; j++) {
           int i = sel[j];
           if (!nullPos[i]) {
-           if (StringExpr.compare(value, 0, value.length, vector[i], start[i], 
length[i]) <OperatorSymbol> 0) {
+           if (<CompareOrEqual>(value, 0, value.length, vector[i], start[i], 
length[i])<OptionalCompare>) {
              sel[newSize++] = i;
            }
           }
@@ -117,7 +117,7 @@ public abstract class <ClassName> extends VectorExpression {
         int newSize = 0;
         for(int i = 0; i != n; i++) {
           if (!nullPos[i]) {
-            if (StringExpr.compare(value, 0, value.length, vector[i], 
start[i], length[i]) <OperatorSymbol> 0) {
+            if (<CompareOrEqual>(value, 0, value.length, vector[i], start[i], 
length[i])<OptionalCompare>) {
               sel[newSize++] = i;
             }
           }

http://git-wip-us.apache.org/repos/asf/hive/blob/c7e1d34b/ql/src/gen/vectorization/ExpressionTemplates/StringGroupColumnCompareStringGroupColumn.txt
----------------------------------------------------------------------
diff --git 
a/ql/src/gen/vectorization/ExpressionTemplates/StringGroupColumnCompareStringGroupColumn.txt
 
b/ql/src/gen/vectorization/ExpressionTemplates/StringGroupColumnCompareStringGroupColumn.txt
index 8ef1d97..e881037 100644
--- 
a/ql/src/gen/vectorization/ExpressionTemplates/StringGroupColumnCompareStringGroupColumn.txt
+++ 
b/ql/src/gen/vectorization/ExpressionTemplates/StringGroupColumnCompareStringGroupColumn.txt
@@ -83,9 +83,9 @@ public class <ClassName> extends VectorExpression {
       outputColVector.noNulls = true;
       if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
         outputColVector.isRepeating = true;
-        int ret = StringExpr.compare(vector1[0], start1[0], length1[0], 
+        <CompareOrEqualReturnType> ret = <CompareOrEqual>(vector1[0], 
start1[0], length1[0], 
                                          vector2[0], start2[0], length2[0]);
-        if (ret <OperatorSymbol> 0) {
+        if (ret<OptionalCompare>) {
           outVector[0] = 1;
         } else {
           outVector[0] = 0;
@@ -94,8 +94,8 @@ public class <ClassName> extends VectorExpression {
         if (batch.selectedInUse) {
           for(int j = 0; j != n; j++) {
             int i = sel[j];
-            if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                   vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                   vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;
@@ -103,8 +103,8 @@ public class <ClassName> extends VectorExpression {
           }
         } else {
           for(int i = 0; i != n; i++) {
-            if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                   vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                   vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;
@@ -115,8 +115,8 @@ public class <ClassName> extends VectorExpression {
         if (batch.selectedInUse) {
           for(int j = 0; j != n; j++) {
             int i = sel[j];
-            if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                   vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                   vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;
@@ -124,8 +124,8 @@ public class <ClassName> extends VectorExpression {
           }
         } else {
           for(int i = 0; i != n; i++) {
-            if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                   vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                   vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;
@@ -135,8 +135,8 @@ public class <ClassName> extends VectorExpression {
       } else if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
           int i = sel[j];
-          if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                 vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                 vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
             outVector[i] = 1;
           } else {
             outVector[i] = 0;
@@ -144,8 +144,8 @@ public class <ClassName> extends VectorExpression {
         }
       } else {
         for(int i = 0; i != n; i++) {
-          if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                 vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                 vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
             outVector[i] = 1;
           } else {
             outVector[i] = 0;
@@ -160,8 +160,8 @@ public class <ClassName> extends VectorExpression {
         outputColVector.isRepeating = true;
         outNull[0] = nullPos2[0];
         if (!nullPos2[0]) {
-          if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                               vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                               vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
             outVector[0] = 1;
           } else {
             outVector[0] = 0;
@@ -175,8 +175,8 @@ public class <ClassName> extends VectorExpression {
             int i = sel[j];
             outNull[i] = nullPos2[i];
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -187,8 +187,8 @@ public class <ClassName> extends VectorExpression {
           for(int i = 0; i != n; i++) {
             outNull[i] = nullPos2[i];
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -207,8 +207,8 @@ public class <ClassName> extends VectorExpression {
           for(int j = 0; j != n; j++) {
             int i = sel[j];
             outNull[i] = false;
-            if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                   vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                   vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;
@@ -217,8 +217,8 @@ public class <ClassName> extends VectorExpression {
         } else {
           for(int i = 0; i != n; i++) {
             outNull[i] = false;
-            if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                   vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                   vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;
@@ -231,8 +231,8 @@ public class <ClassName> extends VectorExpression {
             int i = sel[j];
             outNull[i] = nullPos2[i];
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -243,8 +243,8 @@ public class <ClassName> extends VectorExpression {
           for(int i = 0; i != n; i++) {
             outNull[i] = nullPos2[i];
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -261,8 +261,8 @@ public class <ClassName> extends VectorExpression {
         outputColVector.isRepeating = true;
         outNull[0] = nullPos1[0];
         if (!nullPos1[0]) {
-          if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                               vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                               vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
             outVector[0] = 1;
           } else {
             outVector[0] = 0;
@@ -279,8 +279,8 @@ public class <ClassName> extends VectorExpression {
           for(int j = 0; j != n; j++) {
             int i = sel[j];
             outNull[i] = false;
-            if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                   vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                   vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;
@@ -289,8 +289,8 @@ public class <ClassName> extends VectorExpression {
         } else {
           for(int i = 0; i != n; i++) {
             outNull[i] = false;
-            if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                   vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                   vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;
@@ -303,8 +303,8 @@ public class <ClassName> extends VectorExpression {
             int i = sel[j];
             outNull[i] = nullPos1[i];
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -315,8 +315,8 @@ public class <ClassName> extends VectorExpression {
           for(int i = 0; i != n; i++) {
             outNull[i] = nullPos1[i];
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -330,8 +330,8 @@ public class <ClassName> extends VectorExpression {
             int i = sel[j];
             outNull[i] = nullPos1[i];
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -342,8 +342,8 @@ public class <ClassName> extends VectorExpression {
           for(int i = 0; i != n; i++) {
             outNull[i] = nullPos1[i];
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -360,8 +360,8 @@ public class <ClassName> extends VectorExpression {
         outputColVector.isRepeating = true;
         outNull[0] = nullPos1[0] || nullPos2[0];
         if (!outNull[0]) {
-          if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                             vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                             vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
             outVector[0] = 1;
           } else {
             outVector[0] = 0;
@@ -378,8 +378,8 @@ public class <ClassName> extends VectorExpression {
             int i = sel[j];
             outNull[i] = nullPos2[i];
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -390,8 +390,8 @@ public class <ClassName> extends VectorExpression {
           for(int i = 0; i != n; i++) {
             outNull[i] = nullPos2[i];
             if (!nullPos2[i]) {
-              if (StringExpr.compare(vector1[0], start1[0], length1[0], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[0], start1[0], length1[0], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -410,8 +410,8 @@ public class <ClassName> extends VectorExpression {
             int i = sel[j];
             outNull[i] = nullPos1[i];
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -422,8 +422,8 @@ public class <ClassName> extends VectorExpression {
           for(int i = 0; i != n; i++) {
             outNull[i] = nullPos1[i];
             if (!nullPos1[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[0], start2[0], length2[0]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[0], start2[0], 
length2[0])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -437,8 +437,8 @@ public class <ClassName> extends VectorExpression {
             int i = sel[j];
             outNull[i] = nullPos1[i] || nullPos2[i];
             if (!outNull[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;
@@ -449,8 +449,8 @@ public class <ClassName> extends VectorExpression {
           for(int i = 0; i != n; i++) {
             outNull[i] = nullPos1[i] || nullPos2[i];
             if (!outNull[i]) {
-              if (StringExpr.compare(vector1[i], start1[i], length1[i], 
-                                     vector2[i], start2[i], length2[i]) 
<OperatorSymbol> 0) {
+              if (<CompareOrEqual>(vector1[i], start1[i], length1[i], 
+                                     vector2[i], start2[i], 
length2[i])<OptionalCompare>) {
                 outVector[i] = 1;
               } else {
                 outVector[i] = 0;

http://git-wip-us.apache.org/repos/asf/hive/blob/c7e1d34b/ql/src/gen/vectorization/ExpressionTemplates/StringGroupColumnCompareStringGroupScalarBase.txt
----------------------------------------------------------------------
diff --git 
a/ql/src/gen/vectorization/ExpressionTemplates/StringGroupColumnCompareStringGroupScalarBase.txt
 
b/ql/src/gen/vectorization/ExpressionTemplates/StringGroupColumnCompareStringGroupScalarBase.txt
index 4d65d50..92bf27a 100644
--- 
a/ql/src/gen/vectorization/ExpressionTemplates/StringGroupColumnCompareStringGroupScalarBase.txt
+++ 
b/ql/src/gen/vectorization/ExpressionTemplates/StringGroupColumnCompareStringGroupScalarBase.txt
@@ -63,7 +63,7 @@ public abstract class <ClassName> extends VectorExpression {
       outputColVector.noNulls = true;
       if (inputColVector.isRepeating) {
         outputColVector.isRepeating = true; 
-        if (StringExpr.compare(vector[0], start[0], length[0], value, 0, 
value.length) <OperatorSymbol> 0) {
+        if (<CompareOrEqual>(vector[0], start[0], length[0], value, 0, 
value.length)<OptionalCompare>) {
           outVector[0] = 1;
         } else {
           outVector[0] = 0;
@@ -71,7 +71,7 @@ public abstract class <ClassName> extends VectorExpression {
       } else if (batch.selectedInUse) {
         for(int j=0; j != n; j++) {
           int i = sel[j];
-          if (StringExpr.compare(vector[i], start[i], length[i], value, 0, 
value.length) <OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector[i], start[i], length[i], value, 0, 
value.length)<OptionalCompare>) {
             outVector[i] = 1;
           } else {
             outVector[i] = 0;
@@ -79,7 +79,7 @@ public abstract class <ClassName> extends VectorExpression {
         }
       } else {
         for(int i = 0; i != n; i++) {
-          if (StringExpr.compare(vector[i], start[i], length[i], value, 0, 
value.length) <OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector[i], start[i], length[i], value, 0, 
value.length)<OptionalCompare>) {
             outVector[i] = 1;
           } else {
             outVector[i] = 0;
@@ -92,7 +92,7 @@ public abstract class <ClassName> extends VectorExpression {
         outputColVector.isRepeating = true;
         outNull[0] = nullPos[0];
         if (!nullPos[0]) {
-          if (StringExpr.compare(vector[0], start[0], length[0], value, 0, 
value.length) <OperatorSymbol> 0) {
+          if (<CompareOrEqual>(vector[0], start[0], length[0], value, 0, 
value.length)<OptionalCompare>) {
             outVector[0] = 1;
           } else {
             outVector[0] = 0;
@@ -103,7 +103,7 @@ public abstract class <ClassName> extends VectorExpression {
           int i = sel[j];
           outNull[i] = nullPos[i];
           if (!nullPos[i]) {
-            if (StringExpr.compare(vector[i], start[i], length[i], value, 0, 
value.length) <OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector[i], start[i], length[i], value, 0, 
value.length)<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;
@@ -114,7 +114,7 @@ public abstract class <ClassName> extends VectorExpression {
         for(int i = 0; i != n; i++) {
           outNull[i] = nullPos[i];
           if (!nullPos[i]) {
-            if (StringExpr.compare(vector[i], start[i], length[i], value, 0, 
value.length) <OperatorSymbol> 0) {
+            if (<CompareOrEqual>(vector[i], start[i], length[i], value, 0, 
value.length)<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;

http://git-wip-us.apache.org/repos/asf/hive/blob/c7e1d34b/ql/src/gen/vectorization/ExpressionTemplates/StringGroupScalarCompareStringGroupColumnBase.txt
----------------------------------------------------------------------
diff --git 
a/ql/src/gen/vectorization/ExpressionTemplates/StringGroupScalarCompareStringGroupColumnBase.txt
 
b/ql/src/gen/vectorization/ExpressionTemplates/StringGroupScalarCompareStringGroupColumnBase.txt
index a734281..238dc93 100644
--- 
a/ql/src/gen/vectorization/ExpressionTemplates/StringGroupScalarCompareStringGroupColumnBase.txt
+++ 
b/ql/src/gen/vectorization/ExpressionTemplates/StringGroupScalarCompareStringGroupColumnBase.txt
@@ -63,7 +63,7 @@ public abstract class <ClassName> extends VectorExpression {
       outputColVector.noNulls = true;
       if (inputColVector.isRepeating) {
         outputColVector.isRepeating = true; 
-        if (StringExpr.compare(value, 0, value.length, vector[0], start[0], 
length[0]) <OperatorSymbol> 0) {
+        if (<CompareOrEqual>(value, 0, value.length, vector[0], start[0], 
length[0])<OptionalCompare>) {
           outVector[0] = 1;
         } else {
           outVector[0] = 0;
@@ -71,7 +71,7 @@ public abstract class <ClassName> extends VectorExpression {
       } else if (batch.selectedInUse) {
         for(int j=0; j != n; j++) {
           int i = sel[j];
-          if (StringExpr.compare(value, 0, value.length, vector[i], start[i], 
length[i]) <OperatorSymbol> 0) {
+          if (<CompareOrEqual>(value, 0, value.length, vector[i], start[i], 
length[i])<OptionalCompare>) {
             outVector[i] = 1;
           } else {
             outVector[i] = 0;
@@ -79,7 +79,7 @@ public abstract class <ClassName> extends VectorExpression {
         }
       } else {
         for(int i = 0; i != n; i++) {
-          if (StringExpr.compare(value, 0, value.length, vector[i], start[i], 
length[i]) <OperatorSymbol> 0) {
+          if (<CompareOrEqual>(value, 0, value.length, vector[i], start[i], 
length[i])<OptionalCompare>) {
             outVector[i] = 1;
           } else {
             outVector[i] = 0;
@@ -92,7 +92,7 @@ public abstract class <ClassName> extends VectorExpression {
         outputColVector.isRepeating = true;
         outNull[0] = nullPos[0];
         if (!nullPos[0]) {
-          if (StringExpr.compare(value, 0, value.length, vector[0], start[0], 
length[0]) <OperatorSymbol> 0) {
+          if (<CompareOrEqual>(value, 0, value.length, vector[0], start[0], 
length[0])<OptionalCompare>) {
             outVector[0] = 1;
           } else {
             outVector[0] = 0;
@@ -103,7 +103,7 @@ public abstract class <ClassName> extends VectorExpression {
           int i = sel[j];
           outNull[i] = nullPos[i];
           if (!nullPos[i]) {
-            if (StringExpr.compare(value, 0, value.length, vector[i], 
start[i], length[i]) <OperatorSymbol> 0) {
+            if (<CompareOrEqual>(value, 0, value.length, vector[i], start[i], 
length[i])<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;
@@ -114,7 +114,7 @@ public abstract class <ClassName> extends VectorExpression {
         for(int i = 0; i != n; i++) {
           outNull[i] = nullPos[i];
           if (!nullPos[i]) {
-            if (StringExpr.compare(value, 0, value.length, vector[i], 
start[i], length[i]) <OperatorSymbol> 0) {
+            if (<CompareOrEqual>(value, 0, value.length, vector[i], start[i], 
length[i])<OptionalCompare>) {
               outVector[i] = 1;
             } else {
               outVector[i] = 0;

http://git-wip-us.apache.org/repos/asf/hive/blob/c7e1d34b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringExpr.java
----------------------------------------------------------------------
diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringExpr.java 
b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringExpr.java
index df71d8b..ebeb642 100644
--- 
a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringExpr.java
+++ 
b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringExpr.java
@@ -46,6 +46,30 @@ public class StringExpr {
     return len1 - len2;
   }
 
+  /* Determine if two strings are equal from two byte arrays each
+   * with their own start position and length.
+   * Use lexicographic unsigned byte value order.
+   * This is what's used for UTF-8 sort order.
+   */
+  public static boolean equal(byte[] arg1, int start1, int len1, byte[] arg2, 
int start2, int len2) {
+    if (len1 != len2) {
+      return false;
+    }
+    for (int index1 = start1,
+             index2 = start2;
+         len1 > 0;
+         len1--,
+         index1++,
+         index2++) {
+      // Note the "& 0xff" is just a way to convert unsigned bytes to signed 
integer.
+      if ((arg1[index1] & 0xff) != (arg2[index2] & 0xff)) {
+        return false;
+      }
+
+    }
+    return true;
+  }
+
   public static int characterCount(byte[] bytes) {
     int end = bytes.length;
 

Reply via email to