use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class UnionStringsSketchTest method algebraicIntermediateFinalNullInputTuple.
@Test
public void algebraicIntermediateFinalNullInputTuple() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new UnionStringsSketch().getIntermed()).newInstance();
Tuple resultTuple = func.exec(null);
ItemsSketch<String> sketch = getSketch(resultTuple);
Assert.assertTrue(sketch.isEmpty());
}
use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class UnionStringsSketchTest method algebraicIntermediateFinalWrongType.
@Test(expectedExceptions = IllegalArgumentException.class)
public void algebraicIntermediateFinalWrongType() throws Exception {
@SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new UnionStringsSketch().getIntermed()).newInstance();
DataBag bag = BAG_FACTORY.newDefaultBag();
// this bag must have tuples with either bags or data byte arrays
bag.add(TUPLE_FACTORY.newTuple(1.0));
func.exec(TUPLE_FACTORY.newTuple(bag));
}
use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class DataToSketchTest method testRejectionOfNonSimpleType.
// still triggers unchecked warning
@SuppressWarnings("unchecked")
@Test(expectedExceptions = IllegalArgumentException.class)
public void testRejectionOfNonSimpleType() throws IOException {
TupleFactory mTupleFactory = TupleFactory.getInstance();
BagFactory bagFactory = BagFactory.getInstance();
Tuple outerTuple = mTupleFactory.newTuple(1);
DataBag outerBag = bagFactory.newDefaultBag();
Tuple innerTuple = mTupleFactory.newTuple(1);
DataBag innerBag = bagFactory.newDefaultBag();
innerTuple.set(0, innerBag);
outerBag.add(innerTuple);
outerTuple.set(0, outerBag);
String[] ctorArgs = { "128" };
EvalFunc<Tuple> dataUdf = (EvalFunc<Tuple>) PigContext.instantiateFuncFromSpec(new FuncSpec(udfName, ctorArgs));
dataUdf.exec(outerTuple);
}
use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class MurmurHash3Test method check2ValidArg.
@Test
public void check2ValidArg() throws IOException {
EvalFunc<Tuple> hashUdf = (EvalFunc<Tuple>) PigContext.instantiateFuncFromSpec(new FuncSpec(hashUdfName));
Tuple in, out;
// test String, seed
in = mTupleFactory.newTuple(2);
in.set(0, new String("1"));
// 2nd is null
out = hashUdf.exec(in);
checkOutput(out, false);
in.set(0, new String("1"));
in.set(1, 9001);
out = hashUdf.exec(in);
checkOutput(out, false);
in.set(0, new String("1"));
in.set(1, 9001L);
out = hashUdf.exec(in);
checkOutput(out, false);
}
use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.
the class MurmurHash3Test method checkExceptions5.
@Test(expectedExceptions = IllegalArgumentException.class)
public void checkExceptions5() throws IOException {
EvalFunc<Tuple> hashUdf = (EvalFunc<Tuple>) PigContext.instantiateFuncFromSpec(new FuncSpec(hashUdfName));
Tuple in, out;
// divisor must be INTEGER > 0
in = mTupleFactory.newTuple(3);
in.set(0, new String("ABC"));
in.set(1, 0);
in.set(2, new Integer(0));
out = hashUdf.exec(in);
}
Aggregations