Search in sources :

Example 11 with FuncSpec

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

the class MurmurHash3Test method checkExceptions2.

@Test(expectedExceptions = IllegalArgumentException.class)
public void checkExceptions2() throws IOException {
    EvalFunc<Tuple> hashUdf = (EvalFunc<Tuple>) PigContext.instantiateFuncFromSpec(new FuncSpec(hashUdfName));
    Tuple in, out;
    // seed must be INTEGER or LONG
    in = mTupleFactory.newTuple(2);
    in.set(0, new String("ABC"));
    in.set(1, new Double(9001));
    out = hashUdf.exec(in);
}
Also used : FuncSpec(org.apache.pig.FuncSpec) EvalFunc(org.apache.pig.EvalFunc) Tuple(org.apache.pig.data.Tuple) Test(org.testng.annotations.Test)

Example 12 with FuncSpec

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

the class MurmurHash3Test method checkExceptions3.

@Test(expectedExceptions = IllegalArgumentException.class)
public void checkExceptions3() throws IOException {
    EvalFunc<Tuple> hashUdf = (EvalFunc<Tuple>) PigContext.instantiateFuncFromSpec(new FuncSpec(hashUdfName));
    Tuple in, out;
    // improper hash object = Tuple
    in = mTupleFactory.newTuple(1);
    in.set(0, in);
    out = hashUdf.exec(in);
}
Also used : FuncSpec(org.apache.pig.FuncSpec) EvalFunc(org.apache.pig.EvalFunc) Tuple(org.apache.pig.data.Tuple) Test(org.testng.annotations.Test)

Example 13 with FuncSpec

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

the class MurmurHash3Test method checkExceptions1.

@Test
public void checkExceptions1() throws IOException {
    EvalFunc<Tuple> hashUdf = (EvalFunc<Tuple>) PigContext.instantiateFuncFromSpec(new FuncSpec(hashUdfName));
    Tuple in, out;
    // Empty input tuple
    in = mTupleFactory.newTuple(0);
    out = hashUdf.exec(in);
    Assert.assertNull(out);
}
Also used : FuncSpec(org.apache.pig.FuncSpec) EvalFunc(org.apache.pig.EvalFunc) Tuple(org.apache.pig.data.Tuple) Test(org.testng.annotations.Test)

Aggregations

FuncSpec (org.apache.pig.FuncSpec)13 EvalFunc (org.apache.pig.EvalFunc)12 Tuple (org.apache.pig.data.Tuple)12 Test (org.testng.annotations.Test)12 BagFactory (org.apache.pig.data.BagFactory)2 DataBag (org.apache.pig.data.DataBag)2 DataByteArray (org.apache.pig.data.DataByteArray)2 TupleFactory (org.apache.pig.data.TupleFactory)2 Schema (org.apache.pig.impl.logicalLayer.schema.Schema)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 ArrayList (java.util.ArrayList)1