Search in sources :

Example 26 with DoubleSummary

use of com.yahoo.sketches.tuple.DoubleSummary in project sketches-pig by DataSketches.

the class UnionDoubleSummarySketchTest method accumulatorEmptyInnerTuple.

@Test
public void accumulatorEmptyInnerTuple() throws Exception {
    Accumulator<Tuple> func = new UnionDoubleSummarySketch("32");
    func.accumulate(PigUtil.objectsToTuple(PigUtil.tuplesToBag(TupleFactory.getInstance().newTuple())));
    Tuple resultTuple = func.getValue();
    Assert.assertNotNull(resultTuple);
    Assert.assertEquals(resultTuple.size(), 1);
    DataByteArray bytes = (DataByteArray) resultTuple.get(0);
    Assert.assertTrue(bytes.size() > 0);
    Sketch<DoubleSummary> sketch = Sketches.heapifySketch(Memory.wrap(bytes.get()), new DoubleSummaryDeserializer());
    Assert.assertEquals(sketch.getEstimate(), 0.0);
}
Also used : DoubleSummary(com.yahoo.sketches.tuple.DoubleSummary) DoubleSummaryDeserializer(com.yahoo.sketches.tuple.DoubleSummaryDeserializer) DataByteArray(org.apache.pig.data.DataByteArray) Tuple(org.apache.pig.data.Tuple) Test(org.testng.annotations.Test)

Aggregations

DoubleSummary (com.yahoo.sketches.tuple.DoubleSummary)26 DataByteArray (org.apache.pig.data.DataByteArray)26 Tuple (org.apache.pig.data.Tuple)25 Test (org.testng.annotations.Test)24 DoubleSummaryDeserializer (com.yahoo.sketches.tuple.DoubleSummaryDeserializer)20 DoubleSummaryFactory (com.yahoo.sketches.tuple.DoubleSummaryFactory)13 DataBag (org.apache.pig.data.DataBag)13 UpdatableSketch (com.yahoo.sketches.tuple.UpdatableSketch)8 UpdatableSketchBuilder (com.yahoo.sketches.tuple.UpdatableSketchBuilder)5 UpdateDoublesSketch (com.yahoo.sketches.quantiles.UpdateDoublesSketch)1 Random (java.util.Random)1