use of com.yahoo.sketches.hll.HllSketch in project sketches-pig by DataSketches.
the class DataToSketchTest method execNullInputTuple.
@Test
public void execNullInputTuple() throws Exception {
EvalFunc<DataByteArray> func = new DataToSketch();
DataByteArray result = func.exec(null);
HllSketch sketch = getSketch(result);
Assert.assertTrue(sketch.isEmpty());
}
use of com.yahoo.sketches.hll.HllSketch in project sketches-pig by DataSketches.
the class DataToSketchTest method algebraicFinalFromIntermediate.
@Test
public void algebraicFinalFromIntermediate() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<DataByteArray> func = (EvalFunc<DataByteArray>) Class.forName(new DataToSketch().getFinal()).newInstance();
HllSketch inputSketch = new HllSketch(12);
inputSketch.update("a");
inputSketch.update("b");
DataBag bag = bagFactory.newDefaultBag();
bag.add(tupleFactory.newTuple(new DataByteArray(inputSketch.toCompactByteArray())));
DataByteArray result = func.exec(tupleFactory.newTuple(bag));
HllSketch sketch = getSketch(result);
Assert.assertFalse(sketch.isEmpty());
Assert.assertEquals(sketch.getEstimate(), 2.0, 0.01);
}
use of com.yahoo.sketches.hll.HllSketch in project sketches-pig by DataSketches.
the class DataToSketchTest method algebraicIntermediateEmptyBag.
@Test
public void algebraicIntermediateEmptyBag() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new DataToSketch().getIntermed()).getConstructor(String.class, String.class).newInstance("10", "HLL_6");
Tuple result = func.exec(tupleFactory.newTuple(bagFactory.newDefaultBag()));
HllSketch sketch = getSketch((DataByteArray) result.get(0));
Assert.assertTrue(sketch.isEmpty());
Assert.assertEquals(sketch.getLgConfigK(), 10);
Assert.assertEquals(sketch.getTgtHllType(), TgtHllType.HLL_6);
}
use of com.yahoo.sketches.hll.HllSketch in project sketches-pig by DataSketches.
the class UnionSketchTest method algebraicIntermediateFromIntermediate.
@Test
public void algebraicIntermediateFromIntermediate() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new UnionSketch().getIntermed()).newInstance();
HllSketch inputSketch = new HllSketch(12);
inputSketch.update("a");
inputSketch.update("b");
DataBag bag = bagFactory.newDefaultBag();
bag.add(tupleFactory.newTuple(new DataByteArray(inputSketch.toCompactByteArray())));
Tuple result = func.exec(tupleFactory.newTuple(bag));
HllSketch sketch = DataToSketchTest.getSketch((DataByteArray) result.get(0));
Assert.assertFalse(sketch.isEmpty());
Assert.assertEquals(sketch.getEstimate(), 2.0, 0.01);
}
use of com.yahoo.sketches.hll.HllSketch in project sketches-pig by DataSketches.
the class UnionSketchTest method algebraicIntermediateEmptyInputTuple.
@Test
public void algebraicIntermediateEmptyInputTuple() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new UnionSketch().getIntermed()).getConstructor(String.class).newInstance("10");
Tuple result = func.exec(tupleFactory.newTuple());
HllSketch sketch = DataToSketchTest.getSketch((DataByteArray) result.get(0));
Assert.assertTrue(sketch.isEmpty());
Assert.assertEquals(sketch.getLgConfigK(), 10);
}
Aggregations