use of org.apache.hadoop.hive.ql.udf.generic.GenericUDAFPercentileCont.PercentileContLongEvaluator in project hive by apache.
the class TestGenericUDAFPercentileCont method checkPercentile.
@SuppressWarnings({ "unchecked", "resource" })
private void checkPercentile(Double[] items, double percentile, double expected) throws Exception {
PercentileContDoubleEvaluator eval = new GenericUDAFPercentileCont.PercentileContDoubleEvaluator();
PercentileAgg agg = new PercentileContLongEvaluator().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();
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDAFPercentileCont.PercentileContLongEvaluator in project hive by apache.
the class TestGenericUDAFPercentileCont method checkPercentile.
@SuppressWarnings({ "unchecked", "resource" })
private void checkPercentile(Long[] items, double percentile, double expected) throws Exception {
PercentileContLongEvaluator eval = new GenericUDAFPercentileCont.PercentileContLongEvaluator();
PercentileAgg agg = new PercentileContLongEvaluator().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 LongWritable(items[i]), 1);
}
DoubleWritable result = (DoubleWritable) eval.terminate(agg);
Assert.assertEquals(expected, result.get(), 0.01);
eval.close();
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDAFPercentileCont.PercentileContLongEvaluator in project hive by apache.
the class TestGenericUDAFPercentileDisc method checkPercentile.
private void checkPercentile(Long[] items, double percentile, double expected) throws Exception {
PercentileContLongEvaluator eval = new GenericUDAFPercentileDisc.PercentileDiscLongEvaluator();
PercentileAgg agg = new PercentileContLongEvaluator().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 LongWritable(items[i]), 1);
}
DoubleWritable result = (DoubleWritable) eval.terminate(agg);
Assert.assertEquals(expected, result.get(), 0.01);
eval.close();
}
Aggregations