use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class DataToSketchTest method algebraicInitialWithLgK.
@Test
public void algebraicInitialWithLgK() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new DataToSketch().getInitial()).getConstructor(String.class).newInstance("10");
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 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 org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class DataToSketchTest method algebraicInitialWithLgKAndTgtHllType.
@Test
public void algebraicInitialWithLgKAndTgtHllType() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new DataToSketch().getInitial()).getConstructor(String.class, String.class).newInstance("10", "HLL_6");
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 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 org.apache.pig.EvalFunc 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