@Override
    public void iterate(AggregationBuffer agg, Object[] parameters)
        throws HiveException {
      SumAvgStreamingState ss = (SumAvgStreamingState) agg;

      wrappedEval.iterate(ss.wrappedBuf, parameters);

      // We need to insert 'null' before processing first row for the case: X preceding and y preceding
      if (ss.numRows == 0) {
        for (int i = wFrameDef.getEnd().getRelativeOffset(); i < 0; i++) {
          ss.results.add(null);
        }
      }

      // Generate the result for the windowing ending at the current row
      if (ss.hasResultReady()) {
        ss.results.add(getNextResult(ss));
      }
      if (!wFrameDef.isStartUnbounded()
          && ss.numRows + 1 >= wFrameDef.getStart().getRelativeOffset()) {
        ss.intermediateVals.add(getCurrentIntermediateResult(ss));
      }

      ss.numRows++;
    }
Retrieve the next stored intermediate result, i.e.,
Get S[x-1] in the computation of S[x..y] = S[y] - S[x-1].
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFStreamingEvaluator.java