use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class DataToSketchTest method algebraicIntermediateFromInitial.
@Test
public void algebraicIntermediateFromInitial() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new DataToSketch().getIntermed()).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));
Tuple result = func.exec(tupleFactory.newTuple(outerBag));
HllSketch sketch = getSketch((DataByteArray) result.get(0));
Assert.assertFalse(sketch.isEmpty());
Assert.assertEquals(sketch.getEstimate(), 3.0, 0.01);
}
use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class DataToSketchTest method algebraicFinalEmptyInputTuple.
@Test
public void algebraicFinalEmptyInputTuple() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<DataByteArray> func = (EvalFunc<DataByteArray>) Class.forName(new DataToSketch().getFinal()).getConstructor(String.class).newInstance("10");
DataByteArray result = func.exec(tupleFactory.newTuple());
HllSketch sketch = getSketch(result);
Assert.assertTrue(sketch.isEmpty());
Assert.assertEquals(sketch.getLgConfigK(), 10);
}
use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class DataToSketchTest method algebraicInitial.
@Test
public void algebraicInitial() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new DataToSketch().getInitial()).newInstance();
Tuple input = tupleFactory.newTuple();
Tuple result = func.exec(input);
Assert.assertEquals(result, input);
}
use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class UnionSketchTest method algebraicFinalEmptyInputTuple.
@Test
public void algebraicFinalEmptyInputTuple() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<DataByteArray> func = (EvalFunc<DataByteArray>) Class.forName(new UnionSketch().getFinal()).getConstructor(String.class).newInstance("10");
DataByteArray result = func.exec(tupleFactory.newTuple());
HllSketch sketch = DataToSketchTest.getSketch(result);
Assert.assertTrue(sketch.isEmpty());
Assert.assertEquals(sketch.getLgConfigK(), 10);
}
use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class UnionSketchTest method algebraicInitial.
@Test
public void algebraicInitial() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new UnionSketch().getInitial()).newInstance();
Tuple input = tupleFactory.newTuple();
Tuple result = func.exec(input);
Assert.assertEquals(result, input);
}
Aggregations