use of co.cask.cdap.dq.functions.HistogramWithBucketing in project cdap by caskdata.
the class AggregationFunctionsTest method histogramWithBucketingTest.
@Test
public void histogramWithBucketingTest() throws Exception {
DataQualityWritable val1 = new DataQualityWritable();
DataQualityWritable val2 = new DataQualityWritable();
DataQualityWritable val3 = new DataQualityWritable();
DataQualityWritable val4 = new DataQualityWritable();
DataQualityWritable val5 = new DataQualityWritable();
DataQualityWritable val6 = new DataQualityWritable();
DataQualityWritable val7 = new DataQualityWritable();
DataQualityWritable val8 = new DataQualityWritable();
val1.set(new IntWritable(2));
val2.set(new IntWritable(3));
val3.set(new IntWritable(4));
val4.set(new IntWritable(16));
val5.set(new IntWritable(16));
val6.set(new IntWritable(26));
val7.set(new IntWritable(46));
val8.set(new IntWritable(56));
HistogramWithBucketing histogramWithBucketing = new HistogramWithBucketing();
histogramWithBucketing.add(val1);
histogramWithBucketing.add(val2);
histogramWithBucketing.add(val3);
histogramWithBucketing.add(val4);
histogramWithBucketing.add(val5);
histogramWithBucketing.add(val6);
histogramWithBucketing.add(val7);
histogramWithBucketing.add(val8);
histogramWithBucketing.aggregate();
Map<Map.Entry<Double, Double>, Long> expectedMap = new HashMap<>();
Map.Entry<Double, Double> expectedMapEntry = new AbstractMap.SimpleEntry<>(2.0, 86.0);
expectedMap.put(expectedMapEntry, new Long(8));
Assert.assertEquals(histogramWithBucketing.histogram, expectedMap);
}
Aggregations