hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject [2/3] hive git commit: HIVE-13870 : Decimal vector is not resized correctly (Sergey Shelukhin, reviewed by Matt McCline)
Date Tue, 31 May 2016 19:02:36 GMT
HIVE-13870 : Decimal vector is not resized correctly (Sergey Shelukhin, reviewed by Matt McCline)

Conflicts:
	storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/DecimalColumnVector.java


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

Branch: refs/heads/branch-2.0
Commit: f0e072030062210b3927b9ffbbec97d8e1d66e4d
Parents: e3cfeeb
Author: Sergey Shelukhin <sershe@apache.org>
Authored: Tue May 31 11:48:44 2016 -0700
Committer: Sergey Shelukhin <sershe@apache.org>
Committed: Tue May 31 11:58:54 2016 -0700

----------------------------------------------------------------------
 .../ql/exec/vector/DecimalColumnVector.java     | 32 ++++++++------------
 1 file changed, 13 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/f0e07203/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 1523ff6..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
@@ -140,17 +132,19 @@ public class DecimalColumnVector extends ColumnVector {
 
   @Override
   public void ensureSize(int size, boolean preserveData) {
-    if (size > vector.length) {
-      super.ensureSize(size, preserveData);
-      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);
-        }
-      }
+    super.ensureSize(size, preserveData);
+    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);
     }
   }
 }


Mime
View raw message