use of org.apache.hadoop.hive.ql.udf.generic.GenericUDAFPercentileDisc.PercentileDiscDoubleEvaluator in project hive by apache.
the class TestGenericUDAFPercentileDisc method checkPercentile.
@SuppressWarnings({ "unchecked", "resource" })
private void checkPercentile(Double[] items, double percentile, double expected) throws Exception {
PercentileDiscDoubleEvaluator eval = new GenericUDAFPercentileDisc.PercentileDiscDoubleEvaluator();
PercentileAgg agg = new PercentileDiscDoubleEvaluator().new PercentileAgg();
agg.percentiles = new ArrayList<DoubleWritable>();
agg.percentiles.add(new DoubleWritable(percentile));
agg.isAscending = true;
for (int i = 0; i < items.length; i++) {
eval.increment(agg, new DoubleWritable(items[i]), 1);
}
DoubleWritable result = (DoubleWritable) eval.terminate(agg);
Assert.assertEquals(expected, result.get(), 0.01);
eval.close();
}
Aggregations