hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1494784 - /hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedRowBatch.java
Date Wed, 19 Jun 2013 22:06:01 GMT
Author: hashutosh
Date: Wed Jun 19 22:06:00 2013
New Revision: 1494784

URL: http://svn.apache.org/r1494784
Log:
HIVE-4758 : NULLs and record separators broken with vectorization branch intermediate outputs
(Gopal V via Ashutosh Chauhan)

Modified:
    hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedRowBatch.java

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedRowBatch.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedRowBatch.java?rev=1494784&r1=1494783&r2=1494784&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedRowBatch.java
(original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedRowBatch.java
Wed Jun 19 22:06:00 2013
@@ -23,6 +23,7 @@ import java.io.IOException;
 
 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpressionWriter;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.io.NullWritable;
 import org.apache.hadoop.io.Writable;
 
 /**
@@ -100,6 +101,13 @@ public class VectorizedRowBatch implemen
     return size;
   }
 
+  private String toUTF8(Object o) {
+    if(o == null || o instanceof NullWritable) {
+      return "\\N"; /* as found in LazySimpleSerDe's nullSequence */
+    }
+    return o.toString();
+  }
+
   @Override
   public String toString() {
     if (size == 0) {
@@ -110,18 +118,16 @@ public class VectorizedRowBatch implemen
       if (this.selectedInUse) {
         for (int j = 0; j < size; j++) {
           int i = selected[j];
-          int colIndex = 0;
           for (int k = 0; k < projectionSize; k++) {
             int projIndex = projectedColumns[k];
             ColumnVector cv = cols[projIndex];
+            if (k > 0) {
+              b.append('\u0001');
+            }
             if (cv.isRepeating) {
-              b.append(valueWriters[k].writeValue(cv, 0).toString());
+              b.append(toUTF8(valueWriters[k].writeValue(cv, 0)));
             } else {
-              b.append(valueWriters[k].writeValue(cv, i).toString());
-            }
-            colIndex++;
-            if (colIndex < cols.length) {
-              b.append('\u0001');
+              b.append(toUTF8(valueWriters[k].writeValue(cv, i)));
             }
           }
           if (j < size - 1) {
@@ -130,18 +136,16 @@ public class VectorizedRowBatch implemen
         }
       } else {
         for (int i = 0; i < size; i++) {
-          int colIndex = 0;
           for (int k = 0; k < projectionSize; k++) {
             int projIndex = projectedColumns[k];
             ColumnVector cv = cols[projIndex];
+            if (k > 0) {
+              b.append('\u0001');
+            }
             if (cv.isRepeating) {
-              b.append(valueWriters[k].writeValue(cv, 0).toString());
+              b.append(toUTF8(valueWriters[k].writeValue(cv, 0)));
             } else {
-              b.append(valueWriters[k].writeValue(cv, i).toString());
-            }
-            colIndex++;
-            if (colIndex < cols.length) {
-              b.append('\u0001');
+              b.append(toUTF8(valueWriters[k].writeValue(cv, i)));
             }
           }
           if (i < size - 1) {



Mime
View raw message