use of com.yahoo.sketches.quantiles.UpdateDoublesSketch in project sketches-pig by DataSketches.
the class GetPmfFromDoublesSketchTest method normalCase.
@Test
public void normalCase() throws Exception {
EvalFunc<Tuple> func = new GetPmfFromDoublesSketch();
UpdateDoublesSketch sketch = DoublesSketch.builder().build();
for (int i = 1; i <= 10; i++) sketch.update(i);
Tuple resultTuple = func.exec(tupleFactory.newTuple(Arrays.asList(new DataByteArray(sketch.toByteArray()), 2.0, 7.0)));
Assert.assertNotNull(resultTuple);
Assert.assertEquals(resultTuple.size(), 3);
Assert.assertEquals(((double) resultTuple.get(0)), 0.1);
Assert.assertEquals(((double) resultTuple.get(1)), 0.5);
Assert.assertEquals(((double) resultTuple.get(2)), 0.4);
}
use of com.yahoo.sketches.quantiles.UpdateDoublesSketch in project sketches-pig by DataSketches.
the class GetQuantileFromDoublesSketchTest method normalCase.
@Test
public void normalCase() throws Exception {
EvalFunc<Double> func = new GetQuantileFromDoublesSketch();
UpdateDoublesSketch sketch = DoublesSketch.builder().build();
sketch.update(1.0);
Double result = func.exec(tupleFactory.newTuple(Arrays.asList(new DataByteArray(sketch.toByteArray()), 0.5)));
Assert.assertEquals(result, 1.0);
}
use of com.yahoo.sketches.quantiles.UpdateDoublesSketch in project sketches-pig by DataSketches.
the class GetQuantilesFromDoublesSketchTest method oneFraction.
@Test
public void oneFraction() throws Exception {
EvalFunc<Tuple> func = new GetQuantilesFromDoublesSketch();
UpdateDoublesSketch sketch = DoublesSketch.builder().build();
for (int i = 1; i <= 10; i++) sketch.update(i);
Tuple resultTuple = func.exec(tupleFactory.newTuple(Arrays.asList(new DataByteArray(sketch.toByteArray()), 0.5)));
Assert.assertNotNull(resultTuple);
Assert.assertEquals(resultTuple.size(), 1);
Assert.assertEquals(((double) resultTuple.get(0)), 6.0);
}
use of com.yahoo.sketches.quantiles.UpdateDoublesSketch in project sketches-pig by DataSketches.
the class GetQuantilesFromDoublesSketchTest method severalFractions.
@Test
public void severalFractions() throws Exception {
EvalFunc<Tuple> func = new GetQuantilesFromDoublesSketch();
UpdateDoublesSketch sketch = DoublesSketch.builder().build();
for (int i = 1; i <= 10; i++) sketch.update(i);
Tuple resultTuple = func.exec(tupleFactory.newTuple(Arrays.asList(new DataByteArray(sketch.toByteArray()), 0.0, 0.5, 1.0)));
Assert.assertNotNull(resultTuple);
Assert.assertEquals(resultTuple.size(), 3);
Assert.assertEquals(((double) resultTuple.get(0)), 1.0);
Assert.assertEquals(((double) resultTuple.get(1)), 6.0);
Assert.assertEquals(((double) resultTuple.get(2)), 10.0);
}
use of com.yahoo.sketches.quantiles.UpdateDoublesSketch in project sketches-pig by DataSketches.
the class UnionDoublesSketchTest method execNormalCase.
@Test
public void execNormalCase() throws Exception {
EvalFunc<Tuple> func = new UnionDoublesSketch();
DataBag bag = bagFactory.newDefaultBag();
UpdateDoublesSketch inputSketch = DoublesSketch.builder().build();
inputSketch.update(1.0);
bag.add(tupleFactory.newTuple(new DataByteArray(inputSketch.toByteArray())));
Tuple resultTuple = func.exec(tupleFactory.newTuple(bag));
DoublesSketch sketch = getSketch(resultTuple);
Assert.assertFalse(sketch.isEmpty());
Assert.assertEquals(sketch.getN(), 1);
}
Aggregations