Search in sources :

Example 11 with EvalFunc

use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.

the class UnionSketchTest method algebraicFinalNullInputTuple.

@Test
public void algebraicFinalNullInputTuple() throws Exception {
    @SuppressWarnings("unchecked") EvalFunc<DataByteArray> func = (EvalFunc<DataByteArray>) Class.forName(new UnionSketch().getFinal()).newInstance();
    DataByteArray result = func.exec(null);
    HllSketch sketch = DataToSketchTest.getSketch(result);
    Assert.assertTrue(sketch.isEmpty());
}
Also used : HllSketch(com.yahoo.sketches.hll.HllSketch) EvalFunc(org.apache.pig.EvalFunc) DataByteArray(org.apache.pig.data.DataByteArray) Test(org.testng.annotations.Test)

Example 12 with EvalFunc

use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.

the class UnionSketchTest method algebraicIntermediateNullInputTuple.

@Test
public void algebraicIntermediateNullInputTuple() throws Exception {
    @SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new UnionSketch().getIntermed()).newInstance();
    Tuple result = func.exec(null);
    HllSketch sketch = DataToSketchTest.getSketch((DataByteArray) result.get(0));
    Assert.assertTrue(sketch.isEmpty());
}
Also used : HllSketch(com.yahoo.sketches.hll.HllSketch) EvalFunc(org.apache.pig.EvalFunc) Tuple(org.apache.pig.data.Tuple) Test(org.testng.annotations.Test)

Example 13 with EvalFunc

use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.

the class DataToStringsSketchTest method algebraicIntermediateFinalNullInputTuple.

@Test
public void algebraicIntermediateFinalNullInputTuple() throws Exception {
    @SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new DataToStringsSketch().getIntermed()).newInstance();
    Tuple resultTuple = func.exec(null);
    ItemsSketch<String> sketch = getSketch(resultTuple);
    Assert.assertTrue(sketch.isEmpty());
}
Also used : EvalFunc(org.apache.pig.EvalFunc) Tuple(org.apache.pig.data.Tuple) Test(org.testng.annotations.Test)

Example 14 with EvalFunc

use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.

the class DataToStringsSketchTest method algebraicIntermediateFinalEmptyInputTuple.

@Test
public void algebraicIntermediateFinalEmptyInputTuple() throws Exception {
    @SuppressWarnings("unchecked") EvalFunc<Tuple> func = (EvalFunc<Tuple>) Class.forName(new DataToStringsSketch().getIntermed()).newInstance();
    Tuple resultTuple = func.exec(TUPLE_FACTORY.newTuple());
    ItemsSketch<String> sketch = getSketch(resultTuple);
    Assert.assertTrue(sketch.isEmpty());
}
Also used : EvalFunc(org.apache.pig.EvalFunc) Tuple(org.apache.pig.data.Tuple) Test(org.testng.annotations.Test)

Example 15 with EvalFunc

use of org.apache.pig.EvalFunc in project sketches-pig by DataSketches.

the class MurmurHash3Test method check3ValidArgs.

@Test
public void check3ValidArgs() throws IOException {
    EvalFunc<Tuple> hashUdf = (EvalFunc<Tuple>) PigContext.instantiateFuncFromSpec(new FuncSpec(hashUdfName));
    Tuple in, out;
    // test multiple integers, seed
    in = mTupleFactory.newTuple(3);
    for (int i = 0; i < 10; i++) {
        in.set(0, i);
        in.set(1, 9001);
        in.set(2, 7);
        out = hashUdf.exec(in);
        checkOutput(out, true);
    }
}
Also used : FuncSpec(org.apache.pig.FuncSpec) EvalFunc(org.apache.pig.EvalFunc) Tuple(org.apache.pig.data.Tuple) Test(org.testng.annotations.Test)

Aggregations

EvalFunc (org.apache.pig.EvalFunc)44 Test (org.testng.annotations.Test)44 Tuple (org.apache.pig.data.Tuple)35 HllSketch (com.yahoo.sketches.hll.HllSketch)18 DataBag (org.apache.pig.data.DataBag)16 DataByteArray (org.apache.pig.data.DataByteArray)16 FuncSpec (org.apache.pig.FuncSpec)12 ItemsSketch (com.yahoo.sketches.quantiles.ItemsSketch)2 BagFactory (org.apache.pig.data.BagFactory)2 TupleFactory (org.apache.pig.data.TupleFactory)2 DataToSketch (com.yahoo.sketches.pig.theta.DataToSketch)1 PigUtil.tupleToSketch (com.yahoo.sketches.pig.theta.PigUtil.tupleToSketch)1 Sketch (com.yahoo.sketches.theta.Sketch)1 Schema (org.apache.pig.impl.logicalLayer.schema.Schema)1