public static void NaNToNull(
      DoubleColumnVector v, int[] sel, boolean selectedInUse, int n, boolean convertInfinity) {
    // handle repeating case
    if (v.isRepeating) {
      if ((convertInfinity && Double.isInfinite(v.vector[0])) || Double.isNaN(v.vector[0])){
        v.vector[0] = DoubleColumnVector.NULL_VALUE;
        v.isNull[0] = true;
        v.noNulls = false;
      }
      return;
    }

    if (v.noNulls) {
      if (selectedInUse) {
        for(int j = 0; j != n; j++) {
          int i = sel[j];
          if ((convertInfinity && Double.isInfinite(v.vector[i])) || Double.isNaN(v.vector[i])) {
            v.vector[i] = DoubleColumnVector.NULL_VALUE;
            v.isNull[i] = true;
            v.noNulls = false;
          } else {
            // Must set isNull[i] to false to make sure
            // it gets initialized, in case we set noNulls to true.
            v.isNull[i] = false;
          }
        }
      } else {
        for(int i = 0; i != n; i++) {
          if ((convertInfinity && Double.isInfinite(v.vector[i])) || Double.isNaN(v.vector[i])) {
            v.vector[i] = DoubleColumnVector.NULL_VALUE;
            v.isNull[i] = true;
            v.noNulls = false;
          } else {
            v.isNull[i] = false;
          }
        }
      }
    } else {  // there are nulls, so null array entries are already initialized
      if (selectedInUse) {
        for (int j = 0; j != n; j++) {
          int i = sel[j];
          if((convertInfinity && Double.isInfinite(v.vector[i])) || Double.isNaN(v.vector[i])) {
            v.vector[i] = DoubleColumnVector.NULL_VALUE;
            v.isNull[i] = true;
          }
        }
      } else {
        for (int i = 0; i != n; i++) {
          if((convertInfinity && Double.isInfinite(v.vector[i])) || Double.isNaN(v.vector[i])) {
            v.vector[i] = DoubleColumnVector.NULL_VALUE;
            v.isNull[i] = true;
          }
        }
      }
    }
  }
Math expression evaluation helper functions.
Some of these are referenced from ColumnUnaryFunc.txt.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/MathExpr.java