hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gop...@apache.org
Subject hive git commit: HIVE-12809: Vectorization: fast-path for coalesce if input.noNulls = true (Gopal V, reviewed by Sergey Shelukhin)
Date Fri, 22 Jan 2016 23:43:51 GMT
Repository: hive
Updated Branches:
  refs/heads/master 165430b64 -> ca8662be5


HIVE-12809: Vectorization: fast-path for coalesce if input.noNulls = true (Gopal V, reviewed
by Sergey Shelukhin)

Signed-off-by: Gopal V <gopalv@apache.org>


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

Branch: refs/heads/master
Commit: ca8662be576a78100a8c0515488faf71ad11a50f
Parents: 165430b
Author: Gopal V <gopalv@apache.org>
Authored: Fri Jan 22 15:41:22 2016 -0800
Committer: Gopal V <gopalv@apache.org>
Committed: Fri Jan 22 15:43:33 2016 -0800

----------------------------------------------------------------------
 .../exec/vector/expressions/VectorCoalesce.java | 23 ++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/ca8662be/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorCoalesce.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorCoalesce.java
b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorCoalesce.java
index 8ca84b7..543d7f0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorCoalesce.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorCoalesce.java
@@ -22,6 +22,8 @@ import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
 
+import com.google.common.base.Preconditions;
+
 import java.util.Arrays;
 
 /**
@@ -38,6 +40,7 @@ public class VectorCoalesce extends VectorExpression {
     this();
     this.inputColumns = inputColumns;
     this.outputColumn = outputColumn;
+    Preconditions.checkArgument(this.inputColumns.length > 0);
   }
 
   public VectorCoalesce() {
@@ -61,9 +64,25 @@ public class VectorCoalesce extends VectorExpression {
 
     outputVector.init();
 
-    outputVector.noNulls = false;
+    boolean noNulls = false;
+
+    for (int k = 0; k < inputColumns.length; k++) {
+      ColumnVector cv = batch.cols[inputColumns[k]];
+      // non-nulls in any column qualifies coalesce having no nulls
+      // common case: last column is a constant & non-null
+      noNulls = noNulls || cv.noNulls;
+    }
+
+    outputVector.noNulls = noNulls;
     outputVector.isRepeating = false;
-    if (batch.selectedInUse) {
+
+    ColumnVector first = batch.cols[inputColumns[0]];
+
+    if (first.noNulls && first.isRepeating) {
+      outputVector.isRepeating = true;
+      outputVector.isNull[0] = false;
+      outputVector.setElement(0, 0, first);
+    } else if (batch.selectedInUse) {
       for (int j = 0; j != n; j++) {
         int i = sel[j];
         outputVector.isNull[i] = true;


Mime
View raw message