@Override
  @SuppressWarnings("unchecked")
  public Object runOnRange(int rowNum, Range range, VectorPTFGroupBatches batches)
      throws HiveException {
    Range r1 = new Range(previousRange.getStart(), range.getStart(), batches);
    Range r2 = new Range(previousRange.getEnd(), range.getEnd(), batches);
    Object sum1 = batches.runEvaluatorOnRange(this, r1);
    Object sum2 = batches.runEvaluatorOnRange(this, r2);

    T partial = previousSum == null && sum1 == null ? null
      : minus(computeValue(previousSum), computeValue((T)sum1));

    return partial == null && sum2 == null ? null : plus(computeValue(partial), computeValue((T)sum2));
  }
This optimization is the vectorized counterpart of HIVE-15520.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFEvaluatorAbstractSum.java