You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by go...@apache.org on 2014/11/01 04:12:19 UTC

svn commit: r1635889 - /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorHashKeyWrapper.java

Author: gopalv
Date: Sat Nov  1 03:12:19 2014
New Revision: 1635889

URL: http://svn.apache.org/r1635889
Log:
HIVE-8632: VectorKeyHashWrapper::duplicateTo allocates too many zero sized arrays (Gopal V, reviewed by Gunther Hagleitner)

Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorHashKeyWrapper.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorHashKeyWrapper.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorHashKeyWrapper.java?rev=1635889&r1=1635888&r2=1635889&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorHashKeyWrapper.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorHashKeyWrapper.java Sat Nov  1 03:12:19 2014
@@ -161,27 +161,36 @@ public class VectorHashKeyWrapper extend
   }
 
   public void duplicateTo(VectorHashKeyWrapper clone) {
-    clone.longValues = longValues.clone();
-    clone.doubleValues = doubleValues.clone();
+    clone.longValues = (longValues.length > 0) ? longValues.clone() : EMPTY_LONG_ARRAY;
+    clone.doubleValues = (doubleValues.length > 0) ? doubleValues.clone() : EMPTY_DOUBLE_ARRAY;
     clone.isNull = isNull.clone();
 
-    // Decimal128 requires deep clone
-    clone.decimalValues = new Decimal128[decimalValues.length];
-    for(int i = 0; i < decimalValues.length; ++i) {
-      clone.decimalValues[i] = new Decimal128().update(decimalValues[i]);
+    if (decimalValues.length > 0) {
+      // Decimal128 requires deep clone
+      clone.decimalValues = new Decimal128[decimalValues.length];
+      for (int i = 0; i < decimalValues.length; ++i) {
+        clone.decimalValues[i] = new Decimal128().update(decimalValues[i]);
+      }
+    } else {
+      clone.decimalValues = EMPTY_DECIMAL_ARRAY;
     }
 
-    clone.byteValues = new byte[byteValues.length][];
-    clone.byteStarts = new int[byteValues.length];
-    clone.byteLengths = byteLengths.clone();
-    for (int i = 0; i < byteValues.length; ++i) {
-      // avoid allocation/copy of nulls, because it potentially expensive. branch instead.
-      if (!isNull[longValues.length + doubleValues.length + i]) {
-        clone.byteValues[i] = Arrays.copyOfRange(
-            byteValues[i],
-            byteStarts[i],
-            byteStarts[i] + byteLengths[i]);
+    if (byteLengths.length > 0) {
+      clone.byteValues = new byte[byteValues.length][];
+      clone.byteStarts = new int[byteValues.length];
+      clone.byteLengths = byteLengths.clone();
+      for (int i = 0; i < byteValues.length; ++i) {
+        // avoid allocation/copy of nulls, because it potentially expensive.
+        // branch instead.
+        if (!isNull[longValues.length + doubleValues.length + i]) {
+          clone.byteValues[i] = Arrays.copyOfRange(byteValues[i],
+              byteStarts[i], byteStarts[i] + byteLengths[i]);
+        }
       }
+    } else {
+      clone.byteValues = EMPTY_BYTES_ARRAY;
+      clone.byteStarts = EMPTY_INT_ARRAY;
+      clone.byteLengths = EMPTY_INT_ARRAY;
     }
     clone.hashcode = hashcode;
     assert clone.equals(this);