Search in sources :

Example 1 with Mean

use of co.cask.cdap.dq.functions.Mean in project cdap by caskdata.

the class AggregationFunctionsTest method averageReturnAggregationTest.

@Test
public void averageReturnAggregationTest() throws Exception {
    byte[] val1 = Bytes.toBytes(10.0);
    Mean mean = new Mean();
    Double averageVal = mean.deserialize(val1);
    Assert.assertEquals(10.0, averageVal, 0);
}
Also used : Mean(co.cask.cdap.dq.functions.Mean) Test(org.junit.Test)

Example 2 with Mean

use of co.cask.cdap.dq.functions.Mean in project cdap by caskdata.

the class AggregationFunctionsTest method averageGenerateAggregationTest.

@Test
public void averageGenerateAggregationTest() throws Exception {
    DataQualityWritable val1 = new DataQualityWritable();
    val1.set(new DoubleWritable(2.0));
    DataQualityWritable val2 = new DataQualityWritable();
    val2.set(new DoubleWritable(2.0));
    Mean mean = new Mean();
    mean.add(val1);
    mean.add(val2);
    byte[] output = mean.aggregate();
    Assert.assertEquals(2.0, Bytes.toDouble(output), 0);
}
Also used : Mean(co.cask.cdap.dq.functions.Mean) DoubleWritable(org.apache.hadoop.io.DoubleWritable) DataQualityWritable(co.cask.cdap.dq.DataQualityWritable) Test(org.junit.Test)

Aggregations

Mean (co.cask.cdap.dq.functions.Mean)2 Test (org.junit.Test)2 DataQualityWritable (co.cask.cdap.dq.DataQualityWritable)1 DoubleWritable (org.apache.hadoop.io.DoubleWritable)1