@Override
        protected DoubleWritable getNextResult(
            org.apache.hadoop.hive.ql.udf.generic.GenericUDAFStreamingEvaluator.SumAvgEnhancer<DoubleWritable, Object[]>.SumAvgStreamingState ss)
            throws HiveException {
          SumDoubleAgg myagg = (SumDoubleAgg) ss.wrappedBuf;
          long nonNullCount = myagg.nonNullCount;
          Double r = nonNullCount == 0 ? null : myagg.sum;
          Object[] o = ss.retrieveNextIntermediateValue();
          if (o != null) {
            Double d = (Double) o[0];
            r = r == null ? null : r - d;
            // nonNullCount keeps track of the running count of non null rows. If the number of
            // non null rows dropping out of the window frame is the same as the current number
            // of non null rows, then the sum should be returned as null.
            nonNullCount = nonNullCount - ((Long) o[1]);
          }

          return nonNullCount == 0 ? null : new DoubleWritable(r);
        }
class for storing double sum value.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFSum.java