hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1489091 [3/4] - in /hive/branches/vectorization/ql/src: java/org/apache/hadoop/hive/ql/exec/vector/ java/org/apache/hadoop/hive/ql/exec/vector/expressions/ java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ java/org/apache/hadoop/...
Date Mon, 03 Jun 2013 18:20:24 GMT
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloDoubleColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloDoubleColumn.java Mon Jun  3 18:20:22 2013
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
 
 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 import org.apache.hadoop.hive.ql.exec.vector.*;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
 
@@ -47,7 +48,6 @@ public class LongColModuloDoubleColumn e
     int n = batch.size;
     long[] vector1 = inputColVector1.vector;
     double[] vector2 = inputColVector2.vector;
-
     double[] outputVector = outputColVector.vector;
     
     // return immediately if batch is empty
@@ -55,81 +55,19 @@ public class LongColModuloDoubleColumn e
       return;
     }
     
-    /* Set repeating property to false (the default).
-     * It will be set to true later if needed later.
-     */
-    outputColVector.isRepeating = false;
-
-    //Handle nulls first
-    if (inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isNull[0] = true;
-        outputColVector.isRepeating = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        }
-      }
-    }
-
-
-    //Disregard nulls for processing
+    outputColVector.isRepeating = inputColVector1.isRepeating && inputColVector2.isRepeating;
+    
+    // Handle nulls first  
+    NullUtil.propagateNullsColCol(
+      inputColVector1, inputColVector2, outputColVector, sel, n, batch.selectedInUse);
+          
+    /* Disregard nulls for processing. In other words,
+     * the arithmetic operation is performed even if one or 
+     * more inputs are null. This is to improve speed by avoiding
+     * conditional checks in the inner loop.
+     */ 
     if (inputColVector1.isRepeating && inputColVector2.isRepeating) { 
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector1[0] % vector2[0];
-      outputColVector.isRepeating = true;
     } else if (inputColVector1.isRepeating) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -154,7 +92,7 @@ public class LongColModuloDoubleColumn e
       }
     } else {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector1[i] % vector2[i];
         }
@@ -164,6 +102,14 @@ public class LongColModuloDoubleColumn e
         }
       }
     }
+    
+    /* For the case when the output can have null values, follow 
+     * the convention that the data values must be 1 for long and 
+     * NaN for double. This is to prevent possible later zero-divide errors
+     * in complex arithmetic expressions like col2 / (col1 - 1)
+     * in the case when some col1 entries are null.
+     */
+    NullUtil.setNullDataEntriesDouble(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloDoubleScalar.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloDoubleScalar.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloDoubleScalar.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloDoubleScalar.java Mon Jun  3 18:20:22 2013
@@ -22,6 +22,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 public class LongColModuloDoubleScalar extends VectorExpression {
   private int colNum;
@@ -47,6 +48,7 @@ public class LongColModuloDoubleScalar e
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     long[] vector = inputColVector.vector;
     double[] outputVector = outputColVector.vector;
@@ -57,15 +59,13 @@ public class LongColModuloDoubleScalar e
     }
 
     if (inputColVector.isRepeating) {
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector[0] % value;
+      
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] % value;
         }
@@ -74,10 +74,9 @@ public class LongColModuloDoubleScalar e
           outputVector[i] = vector[i] % value;
         }
       }
-      outputColVector.isRepeating = false;
     } else /* there are nulls */ {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] % value;
           outputIsNull[i] = inputIsNull[i];
@@ -88,8 +87,9 @@ public class LongColModuloDoubleScalar e
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongColumn.java Mon Jun  3 18:20:22 2013
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
 
 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 import org.apache.hadoop.hive.ql.exec.vector.*;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
 
@@ -47,7 +48,6 @@ public class LongColModuloLongColumn ext
     int n = batch.size;
     long[] vector1 = inputColVector1.vector;
     long[] vector2 = inputColVector2.vector;
-
     long[] outputVector = outputColVector.vector;
     
     // return immediately if batch is empty
@@ -55,81 +55,19 @@ public class LongColModuloLongColumn ext
       return;
     }
     
-    /* Set repeating property to false (the default).
-     * It will be set to true later if needed later.
-     */
-    outputColVector.isRepeating = false;
-
-    //Handle nulls first
-    if (inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isNull[0] = true;
-        outputColVector.isRepeating = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        }
-      }
-    }
-
-
-    //Disregard nulls for processing
+    outputColVector.isRepeating = inputColVector1.isRepeating && inputColVector2.isRepeating;
+    
+    // Handle nulls first  
+    NullUtil.propagateNullsColCol(
+      inputColVector1, inputColVector2, outputColVector, sel, n, batch.selectedInUse);
+          
+    /* Disregard nulls for processing. In other words,
+     * the arithmetic operation is performed even if one or 
+     * more inputs are null. This is to improve speed by avoiding
+     * conditional checks in the inner loop.
+     */ 
     if (inputColVector1.isRepeating && inputColVector2.isRepeating) { 
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector1[0] % vector2[0];
-      outputColVector.isRepeating = true;
     } else if (inputColVector1.isRepeating) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -154,7 +92,7 @@ public class LongColModuloLongColumn ext
       }
     } else {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector1[i] % vector2[i];
         }
@@ -164,6 +102,14 @@ public class LongColModuloLongColumn ext
         }
       }
     }
+    
+    /* For the case when the output can have null values, follow 
+     * the convention that the data values must be 1 for long and 
+     * NaN for double. This is to prevent possible later zero-divide errors
+     * in complex arithmetic expressions like col2 / (col1 - 1)
+     * in the case when some col1 entries are null.
+     */
+    NullUtil.setNullDataEntriesLong(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongScalar.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongScalar.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongScalar.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongScalar.java Mon Jun  3 18:20:22 2013
@@ -22,6 +22,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 public class LongColModuloLongScalar extends VectorExpression {
   private int colNum;
@@ -47,6 +48,7 @@ public class LongColModuloLongScalar ext
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     long[] vector = inputColVector.vector;
     long[] outputVector = outputColVector.vector;
@@ -57,15 +59,13 @@ public class LongColModuloLongScalar ext
     }
 
     if (inputColVector.isRepeating) {
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector[0] % value;
+      
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] % value;
         }
@@ -74,10 +74,9 @@ public class LongColModuloLongScalar ext
           outputVector[i] = vector[i] % value;
         }
       }
-      outputColVector.isRepeating = false;
     } else /* there are nulls */ {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] % value;
           outputIsNull[i] = inputIsNull[i];
@@ -88,8 +87,9 @@ public class LongColModuloLongScalar ext
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleColumn.java Mon Jun  3 18:20:22 2013
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
 
 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 import org.apache.hadoop.hive.ql.exec.vector.*;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
 
@@ -47,7 +48,6 @@ public class LongColMultiplyDoubleColumn
     int n = batch.size;
     long[] vector1 = inputColVector1.vector;
     double[] vector2 = inputColVector2.vector;
-
     double[] outputVector = outputColVector.vector;
     
     // return immediately if batch is empty
@@ -55,81 +55,19 @@ public class LongColMultiplyDoubleColumn
       return;
     }
     
-    /* Set repeating property to false (the default).
-     * It will be set to true later if needed later.
-     */
-    outputColVector.isRepeating = false;
-
-    //Handle nulls first
-    if (inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isNull[0] = true;
-        outputColVector.isRepeating = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        }
-      }
-    }
-
-
-    //Disregard nulls for processing
+    outputColVector.isRepeating = inputColVector1.isRepeating && inputColVector2.isRepeating;
+    
+    // Handle nulls first  
+    NullUtil.propagateNullsColCol(
+      inputColVector1, inputColVector2, outputColVector, sel, n, batch.selectedInUse);
+          
+    /* Disregard nulls for processing. In other words,
+     * the arithmetic operation is performed even if one or 
+     * more inputs are null. This is to improve speed by avoiding
+     * conditional checks in the inner loop.
+     */ 
     if (inputColVector1.isRepeating && inputColVector2.isRepeating) { 
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector1[0] * vector2[0];
-      outputColVector.isRepeating = true;
     } else if (inputColVector1.isRepeating) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -154,7 +92,7 @@ public class LongColMultiplyDoubleColumn
       }
     } else {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector1[i] * vector2[i];
         }
@@ -164,6 +102,14 @@ public class LongColMultiplyDoubleColumn
         }
       }
     }
+    
+    /* For the case when the output can have null values, follow 
+     * the convention that the data values must be 1 for long and 
+     * NaN for double. This is to prevent possible later zero-divide errors
+     * in complex arithmetic expressions like col2 / (col1 - 1)
+     * in the case when some col1 entries are null.
+     */
+    NullUtil.setNullDataEntriesDouble(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleScalar.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleScalar.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleScalar.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleScalar.java Mon Jun  3 18:20:22 2013
@@ -22,6 +22,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 public class LongColMultiplyDoubleScalar extends VectorExpression {
   private int colNum;
@@ -47,6 +48,7 @@ public class LongColMultiplyDoubleScalar
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     long[] vector = inputColVector.vector;
     double[] outputVector = outputColVector.vector;
@@ -57,15 +59,13 @@ public class LongColMultiplyDoubleScalar
     }
 
     if (inputColVector.isRepeating) {
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector[0] * value;
+      
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] * value;
         }
@@ -74,10 +74,9 @@ public class LongColMultiplyDoubleScalar
           outputVector[i] = vector[i] * value;
         }
       }
-      outputColVector.isRepeating = false;
     } else /* there are nulls */ {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] * value;
           outputIsNull[i] = inputIsNull[i];
@@ -88,8 +87,9 @@ public class LongColMultiplyDoubleScalar
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongColumn.java Mon Jun  3 18:20:22 2013
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
 
 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 import org.apache.hadoop.hive.ql.exec.vector.*;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
 
@@ -47,7 +48,6 @@ public class LongColMultiplyLongColumn e
     int n = batch.size;
     long[] vector1 = inputColVector1.vector;
     long[] vector2 = inputColVector2.vector;
-
     long[] outputVector = outputColVector.vector;
     
     // return immediately if batch is empty
@@ -55,81 +55,19 @@ public class LongColMultiplyLongColumn e
       return;
     }
     
-    /* Set repeating property to false (the default).
-     * It will be set to true later if needed later.
-     */
-    outputColVector.isRepeating = false;
-
-    //Handle nulls first
-    if (inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isNull[0] = true;
-        outputColVector.isRepeating = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        }
-      }
-    }
-
-
-    //Disregard nulls for processing
+    outputColVector.isRepeating = inputColVector1.isRepeating && inputColVector2.isRepeating;
+    
+    // Handle nulls first  
+    NullUtil.propagateNullsColCol(
+      inputColVector1, inputColVector2, outputColVector, sel, n, batch.selectedInUse);
+          
+    /* Disregard nulls for processing. In other words,
+     * the arithmetic operation is performed even if one or 
+     * more inputs are null. This is to improve speed by avoiding
+     * conditional checks in the inner loop.
+     */ 
     if (inputColVector1.isRepeating && inputColVector2.isRepeating) { 
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector1[0] * vector2[0];
-      outputColVector.isRepeating = true;
     } else if (inputColVector1.isRepeating) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -154,7 +92,7 @@ public class LongColMultiplyLongColumn e
       }
     } else {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector1[i] * vector2[i];
         }
@@ -164,6 +102,14 @@ public class LongColMultiplyLongColumn e
         }
       }
     }
+    
+    /* For the case when the output can have null values, follow 
+     * the convention that the data values must be 1 for long and 
+     * NaN for double. This is to prevent possible later zero-divide errors
+     * in complex arithmetic expressions like col2 / (col1 - 1)
+     * in the case when some col1 entries are null.
+     */
+    NullUtil.setNullDataEntriesLong(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongScalar.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongScalar.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongScalar.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongScalar.java Mon Jun  3 18:20:22 2013
@@ -22,6 +22,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 public class LongColMultiplyLongScalar extends VectorExpression {
   private int colNum;
@@ -47,6 +48,7 @@ public class LongColMultiplyLongScalar e
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     long[] vector = inputColVector.vector;
     long[] outputVector = outputColVector.vector;
@@ -57,15 +59,13 @@ public class LongColMultiplyLongScalar e
     }
 
     if (inputColVector.isRepeating) {
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector[0] * value;
+      
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] * value;
         }
@@ -74,10 +74,9 @@ public class LongColMultiplyLongScalar e
           outputVector[i] = vector[i] * value;
         }
       }
-      outputColVector.isRepeating = false;
     } else /* there are nulls */ {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] * value;
           outputIsNull[i] = inputIsNull[i];
@@ -88,8 +87,9 @@ public class LongColMultiplyLongScalar e
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleColumn.java Mon Jun  3 18:20:22 2013
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
 
 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 import org.apache.hadoop.hive.ql.exec.vector.*;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
 
@@ -47,7 +48,6 @@ public class LongColSubtractDoubleColumn
     int n = batch.size;
     long[] vector1 = inputColVector1.vector;
     double[] vector2 = inputColVector2.vector;
-
     double[] outputVector = outputColVector.vector;
     
     // return immediately if batch is empty
@@ -55,81 +55,19 @@ public class LongColSubtractDoubleColumn
       return;
     }
     
-    /* Set repeating property to false (the default).
-     * It will be set to true later if needed later.
-     */
-    outputColVector.isRepeating = false;
-
-    //Handle nulls first
-    if (inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isNull[0] = true;
-        outputColVector.isRepeating = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        }
-      }
-    }
-
-
-    //Disregard nulls for processing
+    outputColVector.isRepeating = inputColVector1.isRepeating && inputColVector2.isRepeating;
+    
+    // Handle nulls first  
+    NullUtil.propagateNullsColCol(
+      inputColVector1, inputColVector2, outputColVector, sel, n, batch.selectedInUse);
+          
+    /* Disregard nulls for processing. In other words,
+     * the arithmetic operation is performed even if one or 
+     * more inputs are null. This is to improve speed by avoiding
+     * conditional checks in the inner loop.
+     */ 
     if (inputColVector1.isRepeating && inputColVector2.isRepeating) { 
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector1[0] - vector2[0];
-      outputColVector.isRepeating = true;
     } else if (inputColVector1.isRepeating) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -154,7 +92,7 @@ public class LongColSubtractDoubleColumn
       }
     } else {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector1[i] - vector2[i];
         }
@@ -164,6 +102,14 @@ public class LongColSubtractDoubleColumn
         }
       }
     }
+    
+    /* For the case when the output can have null values, follow 
+     * the convention that the data values must be 1 for long and 
+     * NaN for double. This is to prevent possible later zero-divide errors
+     * in complex arithmetic expressions like col2 / (col1 - 1)
+     * in the case when some col1 entries are null.
+     */
+    NullUtil.setNullDataEntriesDouble(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleScalar.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleScalar.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleScalar.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleScalar.java Mon Jun  3 18:20:22 2013
@@ -22,6 +22,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 public class LongColSubtractDoubleScalar extends VectorExpression {
   private int colNum;
@@ -47,6 +48,7 @@ public class LongColSubtractDoubleScalar
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     long[] vector = inputColVector.vector;
     double[] outputVector = outputColVector.vector;
@@ -57,15 +59,13 @@ public class LongColSubtractDoubleScalar
     }
 
     if (inputColVector.isRepeating) {
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector[0] - value;
+      
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] - value;
         }
@@ -74,10 +74,9 @@ public class LongColSubtractDoubleScalar
           outputVector[i] = vector[i] - value;
         }
       }
-      outputColVector.isRepeating = false;
     } else /* there are nulls */ {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] - value;
           outputIsNull[i] = inputIsNull[i];
@@ -88,8 +87,9 @@ public class LongColSubtractDoubleScalar
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongColumn.java Mon Jun  3 18:20:22 2013
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
 
 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 import org.apache.hadoop.hive.ql.exec.vector.*;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
 
@@ -47,7 +48,6 @@ public class LongColSubtractLongColumn e
     int n = batch.size;
     long[] vector1 = inputColVector1.vector;
     long[] vector2 = inputColVector2.vector;
-
     long[] outputVector = outputColVector.vector;
     
     // return immediately if batch is empty
@@ -55,81 +55,19 @@ public class LongColSubtractLongColumn e
       return;
     }
     
-    /* Set repeating property to false (the default).
-     * It will be set to true later if needed later.
-     */
-    outputColVector.isRepeating = false;
-
-    //Handle nulls first
-    if (inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isNull[0] = true;
-        outputColVector.isRepeating = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        }
-      }
-    }
-
-
-    //Disregard nulls for processing
+    outputColVector.isRepeating = inputColVector1.isRepeating && inputColVector2.isRepeating;
+    
+    // Handle nulls first  
+    NullUtil.propagateNullsColCol(
+      inputColVector1, inputColVector2, outputColVector, sel, n, batch.selectedInUse);
+          
+    /* Disregard nulls for processing. In other words,
+     * the arithmetic operation is performed even if one or 
+     * more inputs are null. This is to improve speed by avoiding
+     * conditional checks in the inner loop.
+     */ 
     if (inputColVector1.isRepeating && inputColVector2.isRepeating) { 
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector1[0] - vector2[0];
-      outputColVector.isRepeating = true;
     } else if (inputColVector1.isRepeating) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -154,7 +92,7 @@ public class LongColSubtractLongColumn e
       }
     } else {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector1[i] - vector2[i];
         }
@@ -164,6 +102,14 @@ public class LongColSubtractLongColumn e
         }
       }
     }
+    
+    /* For the case when the output can have null values, follow 
+     * the convention that the data values must be 1 for long and 
+     * NaN for double. This is to prevent possible later zero-divide errors
+     * in complex arithmetic expressions like col2 / (col1 - 1)
+     * in the case when some col1 entries are null.
+     */
+    NullUtil.setNullDataEntriesLong(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongScalar.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongScalar.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongScalar.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongScalar.java Mon Jun  3 18:20:22 2013
@@ -22,6 +22,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 public class LongColSubtractLongScalar extends VectorExpression {
   private int colNum;
@@ -47,6 +48,7 @@ public class LongColSubtractLongScalar e
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     long[] vector = inputColVector.vector;
     long[] outputVector = outputColVector.vector;
@@ -57,15 +59,13 @@ public class LongColSubtractLongScalar e
     }
 
     if (inputColVector.isRepeating) {
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector[0] - value;
+      
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] - value;
         }
@@ -74,10 +74,9 @@ public class LongColSubtractLongScalar e
           outputVector[i] = vector[i] - value;
         }
       }
-      outputColVector.isRepeating = false;
     } else /* there are nulls */ {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] - value;
           outputIsNull[i] = inputIsNull[i];
@@ -88,8 +87,9 @@ public class LongColSubtractLongScalar e
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarAddDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarAddDoubleColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarAddDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarAddDoubleColumn.java Mon Jun  3 18:20:22 2013
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 /**
  * Implements a vectorized arithmetic operator with a scalar on the left and a
@@ -62,6 +63,7 @@ public class LongScalarAddDoubleColumn e
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     double[] vector = inputColVector.vector;
     double[] outputVector = outputColVector.vector;
@@ -72,16 +74,10 @@ public class LongScalarAddDoubleColumn e
     }
 
     if (inputColVector.isRepeating) {
-    
-      /*
-       * All must be selected otherwise size would be zero
-       * Repeating property will not change.
-       */
       outputVector[0] = value + vector[0];
       
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -93,7 +89,6 @@ public class LongScalarAddDoubleColumn e
           outputVector[i] = value + vector[i];
         }
       }
-      outputColVector.isRepeating = false;
     } else {                         /* there are nulls */ 
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -107,8 +102,9 @@ public class LongScalarAddDoubleColumn e
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarAddLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarAddLongColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarAddLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarAddLongColumn.java Mon Jun  3 18:20:22 2013
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 /**
  * Implements a vectorized arithmetic operator with a scalar on the left and a
@@ -62,6 +63,7 @@ public class LongScalarAddLongColumn ext
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     long[] vector = inputColVector.vector;
     long[] outputVector = outputColVector.vector;
@@ -72,16 +74,10 @@ public class LongScalarAddLongColumn ext
     }
 
     if (inputColVector.isRepeating) {
-    
-      /*
-       * All must be selected otherwise size would be zero
-       * Repeating property will not change.
-       */
       outputVector[0] = value + vector[0];
       
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -93,7 +89,6 @@ public class LongScalarAddLongColumn ext
           outputVector[i] = value + vector[i];
         }
       }
-      outputColVector.isRepeating = false;
     } else {                         /* there are nulls */ 
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -107,8 +102,9 @@ public class LongScalarAddLongColumn ext
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarDivideDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarDivideDoubleColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarDivideDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarDivideDoubleColumn.java Mon Jun  3 18:20:22 2013
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 /**
  * Implements a vectorized arithmetic operator with a scalar on the left and a
@@ -62,6 +63,7 @@ public class LongScalarDivideDoubleColum
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     double[] vector = inputColVector.vector;
     double[] outputVector = outputColVector.vector;
@@ -72,16 +74,10 @@ public class LongScalarDivideDoubleColum
     }
 
     if (inputColVector.isRepeating) {
-    
-      /*
-       * All must be selected otherwise size would be zero
-       * Repeating property will not change.
-       */
       outputVector[0] = value / vector[0];
       
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -93,7 +89,6 @@ public class LongScalarDivideDoubleColum
           outputVector[i] = value / vector[i];
         }
       }
-      outputColVector.isRepeating = false;
     } else {                         /* there are nulls */ 
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -107,8 +102,9 @@ public class LongScalarDivideDoubleColum
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarModuloDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarModuloDoubleColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarModuloDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarModuloDoubleColumn.java Mon Jun  3 18:20:22 2013
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 /**
  * Implements a vectorized arithmetic operator with a scalar on the left and a
@@ -62,6 +63,7 @@ public class LongScalarModuloDoubleColum
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     double[] vector = inputColVector.vector;
     double[] outputVector = outputColVector.vector;
@@ -72,16 +74,10 @@ public class LongScalarModuloDoubleColum
     }
 
     if (inputColVector.isRepeating) {
-    
-      /*
-       * All must be selected otherwise size would be zero
-       * Repeating property will not change.
-       */
       outputVector[0] = value % vector[0];
       
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -93,7 +89,6 @@ public class LongScalarModuloDoubleColum
           outputVector[i] = value % vector[i];
         }
       }
-      outputColVector.isRepeating = false;
     } else {                         /* there are nulls */ 
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -107,8 +102,9 @@ public class LongScalarModuloDoubleColum
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarModuloLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarModuloLongColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarModuloLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarModuloLongColumn.java Mon Jun  3 18:20:22 2013
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 /**
  * Implements a vectorized arithmetic operator with a scalar on the left and a
@@ -62,6 +63,7 @@ public class LongScalarModuloLongColumn 
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     long[] vector = inputColVector.vector;
     long[] outputVector = outputColVector.vector;
@@ -72,16 +74,10 @@ public class LongScalarModuloLongColumn 
     }
 
     if (inputColVector.isRepeating) {
-    
-      /*
-       * All must be selected otherwise size would be zero
-       * Repeating property will not change.
-       */
       outputVector[0] = value % vector[0];
       
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -93,7 +89,6 @@ public class LongScalarModuloLongColumn 
           outputVector[i] = value % vector[i];
         }
       }
-      outputColVector.isRepeating = false;
     } else {                         /* there are nulls */ 
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -107,8 +102,9 @@ public class LongScalarModuloLongColumn 
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarMultiplyDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarMultiplyDoubleColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarMultiplyDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarMultiplyDoubleColumn.java Mon Jun  3 18:20:22 2013
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 /**
  * Implements a vectorized arithmetic operator with a scalar on the left and a
@@ -62,6 +63,7 @@ public class LongScalarMultiplyDoubleCol
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     double[] vector = inputColVector.vector;
     double[] outputVector = outputColVector.vector;
@@ -72,16 +74,10 @@ public class LongScalarMultiplyDoubleCol
     }
 
     if (inputColVector.isRepeating) {
-    
-      /*
-       * All must be selected otherwise size would be zero
-       * Repeating property will not change.
-       */
       outputVector[0] = value * vector[0];
       
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -93,7 +89,6 @@ public class LongScalarMultiplyDoubleCol
           outputVector[i] = value * vector[i];
         }
       }
-      outputColVector.isRepeating = false;
     } else {                         /* there are nulls */ 
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -107,8 +102,9 @@ public class LongScalarMultiplyDoubleCol
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarMultiplyLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarMultiplyLongColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarMultiplyLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarMultiplyLongColumn.java Mon Jun  3 18:20:22 2013
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 /**
  * Implements a vectorized arithmetic operator with a scalar on the left and a
@@ -62,6 +63,7 @@ public class LongScalarMultiplyLongColum
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     long[] vector = inputColVector.vector;
     long[] outputVector = outputColVector.vector;
@@ -72,16 +74,10 @@ public class LongScalarMultiplyLongColum
     }
 
     if (inputColVector.isRepeating) {
-    
-      /*
-       * All must be selected otherwise size would be zero
-       * Repeating property will not change.
-       */
       outputVector[0] = value * vector[0];
       
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -93,7 +89,6 @@ public class LongScalarMultiplyLongColum
           outputVector[i] = value * vector[i];
         }
       }
-      outputColVector.isRepeating = false;
     } else {                         /* there are nulls */ 
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -107,8 +102,9 @@ public class LongScalarMultiplyLongColum
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarSubtractDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarSubtractDoubleColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarSubtractDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarSubtractDoubleColumn.java Mon Jun  3 18:20:22 2013
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 /**
  * Implements a vectorized arithmetic operator with a scalar on the left and a
@@ -62,6 +63,7 @@ public class LongScalarSubtractDoubleCol
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     double[] vector = inputColVector.vector;
     double[] outputVector = outputColVector.vector;
@@ -72,16 +74,10 @@ public class LongScalarSubtractDoubleCol
     }
 
     if (inputColVector.isRepeating) {
-    
-      /*
-       * All must be selected otherwise size would be zero
-       * Repeating property will not change.
-       */
       outputVector[0] = value - vector[0];
       
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -93,7 +89,6 @@ public class LongScalarSubtractDoubleCol
           outputVector[i] = value - vector[i];
         }
       }
-      outputColVector.isRepeating = false;
     } else {                         /* there are nulls */ 
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -107,8 +102,9 @@ public class LongScalarSubtractDoubleCol
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarSubtractLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarSubtractLongColumn.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarSubtractLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongScalarSubtractLongColumn.java Mon Jun  3 18:20:22 2013
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 /**
  * Implements a vectorized arithmetic operator with a scalar on the left and a
@@ -62,6 +63,7 @@ public class LongScalarSubtractLongColum
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     long[] vector = inputColVector.vector;
     long[] outputVector = outputColVector.vector;
@@ -72,16 +74,10 @@ public class LongScalarSubtractLongColum
     }
 
     if (inputColVector.isRepeating) {
-    
-      /*
-       * All must be selected otherwise size would be zero
-       * Repeating property will not change.
-       */
       outputVector[0] = value - vector[0];
       
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -93,7 +89,6 @@ public class LongScalarSubtractLongColum
           outputVector[i] = value - vector[i];
         }
       }
-      outputColVector.isRepeating = false;
     } else {                         /* there are nulls */ 
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -107,8 +102,9 @@ public class LongScalarSubtractLongColum
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/CodeGen.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/CodeGen.java?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/CodeGen.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/CodeGen.java Mon Jun  3 18:20:22 2013
@@ -530,6 +530,7 @@ public class CodeGen {
     templateString = templateString.replaceAll("<OperandType1>", operandType1);
     templateString = templateString.replaceAll("<OperandType2>", operandType2);
     templateString = templateString.replaceAll("<ReturnType>", returnType);
+    templateString = templateString.replaceAll("<CamelReturnType>", getCamelCaseType(returnType));
     writeFile(outputFile, templateString);
 
     if(returnType==null){
@@ -669,7 +670,10 @@ public class CodeGen {
     return b.toString();
   }
 
-   static String getCamelCaseType(String type) {
+  static String getCamelCaseType(String type) {
+    if (type == null) {
+      return null;
+    }
     if (type.equals("long")) {
       return "Long";
     } else if (type.equals("double")) {

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticColumn.txt
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticColumn.txt?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticColumn.txt (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticColumn.txt Mon Jun  3 18:20:22 2013
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
 
 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 import org.apache.hadoop.hive.ql.exec.vector.*;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
 
@@ -47,7 +48,6 @@ public class <ClassName> extends VectorE
     int n = batch.size;
     <OperandType1>[] vector1 = inputColVector1.vector;
     <OperandType2>[] vector2 = inputColVector2.vector;
-
     <ReturnType>[] outputVector = outputColVector.vector;
     
     // return immediately if batch is empty
@@ -55,81 +55,19 @@ public class <ClassName> extends VectorE
       return;
     }
     
-    /* Set repeating property to false (the default).
-     * It will be set to true later if needed later.
-     */
-    outputColVector.isRepeating = false;
-
-    //Handle nulls first
-    if (inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isNull[0] = true;
-        outputColVector.isRepeating = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector2.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i];
-          }
-        }
-      }
-    } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
-      outputColVector.noNulls = false;
-      if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
-        //Output will also be repeating and null
-        outputColVector.isRepeating = true;
-        outputColVector.isNull[0] = true;
-        //return as no further processing is needed
-        return;
-      } else {
-        if (batch.selectedInUse) {
-          for(int j = 0; j != n; j++) {
-            int i = sel[j];
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        } else {
-          for(int i = 0; i != n; i++) {
-            outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
-          }
-        }
-      }
-    }
-
-
-    //Disregard nulls for processing
+    outputColVector.isRepeating = inputColVector1.isRepeating && inputColVector2.isRepeating;
+    
+    // Handle nulls first  
+    NullUtil.propagateNullsColCol(
+      inputColVector1, inputColVector2, outputColVector, sel, n, batch.selectedInUse);
+          
+    /* Disregard nulls for processing. In other words,
+     * the arithmetic operation is performed even if one or 
+     * more inputs are null. This is to improve speed by avoiding
+     * conditional checks in the inner loop.
+     */ 
     if (inputColVector1.isRepeating && inputColVector2.isRepeating) { 
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector1[0] <OperatorSymbol> vector2[0];
-      outputColVector.isRepeating = true;
     } else if (inputColVector1.isRepeating) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -154,7 +92,7 @@ public class <ClassName> extends VectorE
       }
     } else {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector1[i] <OperatorSymbol> vector2[i];
         }
@@ -164,6 +102,14 @@ public class <ClassName> extends VectorE
         }
       }
     }
+    
+    /* For the case when the output can have null values, follow 
+     * the convention that the data values must be 1 for long and 
+     * NaN for double. This is to prevent possible later zero-divide errors
+     * in complex arithmetic expressions like col2 / (col1 - 1)
+     * in the case when some col1 entries are null.
+     */
+    NullUtil.setNullDataEntries<CamelReturnType>(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticScalar.txt
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticScalar.txt?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticScalar.txt (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticScalar.txt Mon Jun  3 18:20:22 2013
@@ -22,6 +22,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.<InputColumnVectorType>;
 import org.apache.hadoop.hive.ql.exec.vector.<OutputColumnVectorType>;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 public class <ClassName> extends VectorExpression {
   private int colNum;
@@ -47,6 +48,7 @@ public class <ClassName> extends VectorE
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     <OperandType1>[] vector = inputColVector.vector;
     <ReturnType>[] outputVector = outputColVector.vector;
@@ -57,15 +59,13 @@ public class <ClassName> extends VectorE
     }
 
     if (inputColVector.isRepeating) {
-      //All must be selected otherwise size would be zero
-      //Repeating property will not change.
       outputVector[0] = vector[0] <OperatorSymbol> value;
+      
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] <OperatorSymbol> value;
         }
@@ -74,10 +74,9 @@ public class <ClassName> extends VectorE
           outputVector[i] = vector[i] <OperatorSymbol> value;
         }
       }
-      outputColVector.isRepeating = false;
     } else /* there are nulls */ {
       if (batch.selectedInUse) {
-        for(int j=0; j != n; j++) {
+        for(int j = 0; j != n; j++) {
           int i = sel[j];
           outputVector[i] = vector[i] <OperatorSymbol> value;
           outputIsNull[i] = inputIsNull[i];
@@ -88,8 +87,9 @@ public class <ClassName> extends VectorE
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override

Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ScalarArithmeticColumn.txt
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ScalarArithmeticColumn.txt?rev=1489091&r1=1489090&r2=1489091&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ScalarArithmeticColumn.txt (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ScalarArithmeticColumn.txt Mon Jun  3 18:20:22 2013
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.ve
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
 
 /**
  * Implements a vectorized arithmetic operator with a scalar on the left and a
@@ -62,6 +63,7 @@ public class <ClassName> extends VectorE
     boolean[] inputIsNull = inputColVector.isNull;
     boolean[] outputIsNull = outputColVector.isNull;
     outputColVector.noNulls = inputColVector.noNulls;
+    outputColVector.isRepeating = inputColVector.isRepeating;
     int n = batch.size;
     <OperandType2>[] vector = inputColVector.vector;
     <ReturnType>[] outputVector = outputColVector.vector;
@@ -72,16 +74,10 @@ public class <ClassName> extends VectorE
     }
 
     if (inputColVector.isRepeating) {
-    
-      /*
-       * All must be selected otherwise size would be zero
-       * Repeating property will not change.
-       */
       outputVector[0] = value <OperatorSymbol> vector[0];
       
       // Even if there are no nulls, we always copy over entry 0. Simplifies code.
       outputIsNull[0] = inputIsNull[0]; 
-      outputColVector.isRepeating = true;
     } else if (inputColVector.noNulls) {
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -93,7 +89,6 @@ public class <ClassName> extends VectorE
           outputVector[i] = value <OperatorSymbol> vector[i];
         }
       }
-      outputColVector.isRepeating = false;
     } else {                         /* there are nulls */ 
       if (batch.selectedInUse) {
         for(int j = 0; j != n; j++) {
@@ -107,8 +102,9 @@ public class <ClassName> extends VectorE
         }
         System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
       }
-      outputColVector.isRepeating = false;
     }
+    
+    NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
   }
 
   @Override



Mime
View raw message