Repository: orc Updated Branches: refs/heads/master bfbdc504a -> 7a4fe255e
HIVE-13870. Decimal vector is not resized correctly. Signed-off-by: Owen O'Malley <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/orc/repo Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/cb58b993 Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/cb58b993 Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/cb58b993 Branch: refs/heads/master Commit: cb58b993c58dad0dbb1f7c4c95c340eb7a4de4c1 Parents: bfbdc50 Author: Owen O'Malley <[email protected]> Authored: Tue May 31 14:19:28 2016 -0700 Committer: Owen O'Malley <[email protected]> Committed: Tue May 31 14:20:55 2016 -0700 ---------------------------------------------------------------------- .../ql/exec/vector/DecimalColumnVector.java | 30 ++++++++------------ 1 file changed, 12 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/orc/blob/cb58b993/java/storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/DecimalColumnVector.java ---------------------------------------------------------------------- diff --git a/java/storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/DecimalColumnVector.java b/java/storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/DecimalColumnVector.java index 0c52210..2488631 100644 --- a/java/storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/DecimalColumnVector.java +++ b/java/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); } } }
