protected List<DoubleWritable> calculatePercentile(List<DoubleWritable> percentiles,
        List<Map.Entry<U, LongWritable>> entriesList, long total, List<DoubleWritable> results) {
      // maxPosition is the 1.0 percentile
      long maxPosition = total - 1;
      for (int i = 0; i < percentiles.size(); ++i) {
        DoubleWritable percentile = percentiles.get(i);
        double position = maxPosition * percentile.get();
        results.get(i).set(calc.getPercentile(entriesList, position));
      }

      return results;
    }
A state class to store intermediate aggregation results.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFPercentileCont.java