@Override
  public void evaluateGroupBatch(VectorizedRowBatch batch)
      throws HiveException {

    evaluateInputExpr(batch);

    // Sum all non-null long column values; maintain isNull.

    // We do not filter when PTF is in reducer.
    Preconditions.checkState(!batch.selectedInUse);

    final int size = batch.size;
    if (size == 0) {
      return;
    }
    LongColumnVector longColVector = ((LongColumnVector) batch.cols[inputColumnNum]);

    LongColumnVector outputColVector = (LongColumnVector) batch.cols[outputColumnNum];
    long[] outputVector = outputColVector.vector;

    if (longColVector.isRepeating) {

      if (longColVector.noNulls || !longColVector.isNull[0]) {

        // We have a repeated value.
        isNull = false;
        final long repeatedValue = longColVector.vector[0];

        for (int i = 0; i < size; i++) {
          sum += repeatedValue;

          // Output row i sum.
          outputVector[i] = sum;
        }
      } else {
        if (isNull) {
          outputColVector.isNull[0] = true;
          outputColVector.noNulls = false;
        } else {

          // Continue previous SUM.
          outputVector[0] = sum;
        }
        outputColVector.isRepeating = true;
      }
    } else if (longColVector.noNulls) {
      isNull = false;
      long[] vector = longColVector.vector;
      for (int i = 0; i < size; i++) {
        sum += vector[i];

        // Output row i sum.
        outputVector[i] = sum;
      }
    } else {
      boolean[] batchIsNull = longColVector.isNull;
      int i = 0;
      while (batchIsNull[i]) {
        if (isNull) {
          outputColVector.isNull[i] = true;
          outputColVector.noNulls = false;
        } else {

          // Continue previous SUM.
          outputVector[i] = sum;
        }
        if (++i >= size) {
          return;
        }
      }

      isNull = false;
      long[] vector = longColVector.vector;

      sum += vector[i];

      // Output row i sum.
      outputVector[i++] = sum;

      for (; i < size; i++) {
        if (!batchIsNull[i]) {
          sum += vector[i];

          // Output row i sum.
          outputVector[i] = sum;
        } else {

          // Continue previous SUM.
          outputVector[i] = sum;
        }
      }
    }
  }
This class evaluates long sum() for a PTF group.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFEvaluatorStreamingLongSum.java