use of com.yahoo.sketches.hll.HllSketch in project sketches-pig by DataSketches.
the class DataToSketchTest method algebraicFinalFromInitial.
@Test
public void algebraicFinalFromInitial() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<DataByteArray> func = (EvalFunc<DataByteArray>) Class.forName(new DataToSketch().getFinal()).newInstance();
DataBag outerBag = bagFactory.newDefaultBag();
DataBag innerBag = bagFactory.newDefaultBag();
innerBag.add(tupleFactory.newTuple("a"));
innerBag.add(tupleFactory.newTuple("b"));
innerBag.add(tupleFactory.newTuple("c"));
outerBag.add(tupleFactory.newTuple(innerBag));
DataByteArray result = func.exec(tupleFactory.newTuple(outerBag));
HllSketch sketch = getSketch(result);
Assert.assertFalse(sketch.isEmpty());
Assert.assertEquals(sketch.getEstimate(), 3.0, 0.01);
}
use of com.yahoo.sketches.hll.HllSketch in project sketches-pig by DataSketches.
the class DataToSketchTest method execEmptyInputTuple.
@Test
public void execEmptyInputTuple() throws Exception {
EvalFunc<DataByteArray> func = new DataToSketch("10");
DataByteArray result = func.exec(tupleFactory.newTuple());
HllSketch sketch = getSketch(result);
Assert.assertTrue(sketch.isEmpty());
Assert.assertEquals(sketch.getLgConfigK(), 10);
}
use of com.yahoo.sketches.hll.HllSketch in project sketches-pig by DataSketches.
the class DataToSketchTest method algebraicFinalNullInputTuple.
@Test
public void algebraicFinalNullInputTuple() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<DataByteArray> func = (EvalFunc<DataByteArray>) Class.forName(new DataToSketch().getFinal()).newInstance();
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 algebraicIntermediateNullInputTuple.
@Test
public void algebraicIntermediateNullInputTuple() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new DataToSketch().getIntermed()).newInstance();
Tuple result = func.exec(null);
HllSketch sketch = getSketch((DataByteArray) result.get(0));
Assert.assertTrue(sketch.isEmpty());
}
use of com.yahoo.sketches.hll.HllSketch in project sketches-pig by DataSketches.
the class DataToSketchTest method algebraicFinalEmptyBag.
@Test
public void algebraicFinalEmptyBag() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<DataByteArray> func = (EvalFunc<DataByteArray>) Class.forName(new DataToSketch().getFinal()).getConstructor(String.class, String.class).newInstance("10", "HLL_6");
DataByteArray result = func.exec(tupleFactory.newTuple(bagFactory.newDefaultBag()));
HllSketch sketch = getSketch(result);
Assert.assertTrue(sketch.isEmpty());
Assert.assertEquals(sketch.getLgConfigK(), 10);
Assert.assertEquals(sketch.getTgtHllType(), TgtHllType.HLL_6);
}
Aggregations