You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2016/05/31 19:02:37 UTC

[3/3] hive git commit: HIVE-13870 : Decimal vector is not resized correctly (Sergey Shelukhin, reviewed by Matt McCline)

HIVE-13870 : Decimal vector is not resized correctly (Sergey Shelukhin, reviewed by Matt McCline)


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

Branch: refs/heads/master
Commit: acdc31b8d3c2b85e4b7882422f5a35cf8665eb8d
Parents: b7166d7
Author: Sergey Shelukhin <se...@apache.org>
Authored: Tue May 31 11:48:44 2016 -0700
Committer: Sergey Shelukhin <se...@apache.org>
Committed: Tue May 31 11:59:09 2016 -0700

----------------------------------------------------------------------
 .../ql/exec/vector/DecimalColumnVector.java     | 30 ++++++++------------
 1 file changed, 12 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/acdc31b8/storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/DecimalColumnVector.java
----------------------------------------------------------------------
diff --git a/storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/DecimalColumnVector.java b/storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/DecimalColumnVector.java
index 0c52210..2488631 100644
--- a/storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/DecimalColumnVector.java
+++ b/storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/DecimalColumnVector.java
@@ -60,14 +60,6 @@ public class DecimalColumnVector extends ColumnVector {
     }
   }
 
-  // Fill the column vector with nulls
-  public void fillWithNulls() {
-    noNulls = false;
-    isRepeating = true;
-    vector[0] = null;
-    isNull[0] = true;
-  }
-
   @Override
   public void flatten(boolean selectedInUse, int[] sel, int size) {
     // TODO Auto-generated method stub
@@ -141,16 +133,18 @@ public class DecimalColumnVector extends ColumnVector {
   @Override
   public void ensureSize(int size, boolean preserveData) {
     super.ensureSize(size, preserveData);
-    if (size > vector.length) {
-      HiveDecimalWritable[] oldArray = vector;
-      vector = new HiveDecimalWritable[size];
-      if (preserveData) {
-        // we copy all of the values to avoid creating more objects
-        System.arraycopy(oldArray, 0, vector, 0 , oldArray.length);
-        for(int i= oldArray.length; i < vector.length; ++i) {
-          vector[i] = new HiveDecimalWritable(HiveDecimal.ZERO);
-        }
-      }
+    if (size <= vector.length) return; // We assume the existing vector is always valid.
+    HiveDecimalWritable[] oldArray = vector;
+    vector = new HiveDecimalWritable[size];
+    int initPos = 0;
+    if (preserveData) {
+      // we copy all of the values to avoid creating more objects
+      // TODO: it might be cheaper to always preserve data or reset existing objects
+      initPos = oldArray.length;
+      System.arraycopy(oldArray, 0, vector, 0 , oldArray.length);
+    }
+    for (int i = initPos; i < vector.length; ++i) {
+      vector[i] = new HiveDecimalWritable(HiveDecimal.ZERO);
     }
   }
 }