@Override
  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);

    // don't reset this evaluator after calculation
    batches.runEvaluatorOnRange(this, r1, false);
    T sum1 = computeValue(sum);
    int count1 = nonNullGroupCount;
    resetEvaluator();

    batches.runEvaluatorOnRange(this, r2, false);
    T sum2 = computeValue(sum);
    int count2 = nonNullGroupCount;
    resetEvaluator();

    sum = plus(minus(computeValue(previousSum), sum1), sum2);
    nonNullGroupCount = previousCount - count1 + count2;

    return divide(sum, nonNullGroupCount);
  }
This optimization is the vectorized counterpart of HIVE-15617.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFEvaluatorAbstractAvg.java