Search in sources :

Example 1 with InvokeForInt

use of com.twitter.elephantbird.pig.piggybank.InvokeForInt in project elephant-bird by twitter.

the class TestInvoker method testArrayConversion.

@Test
public void testArrayConversion() throws SecurityException, ClassNotFoundException, NoSuchMethodException, IOException {
    InvokeForInt id = new InvokeForInt(TestInvoker.class.getName() + ".avg", "double[]");
    DataBag nums = newSimpleBag(1.0, 2.0, 3.0);
    assertEquals(Integer.valueOf(2), id.exec(tf_.newTuple(nums)));
    InvokeForString is = new InvokeForString(TestInvoker.class.getName() + ".concatStringArray", "string[]");
    DataBag strings = newSimpleBag("foo", "bar", "baz");
    assertEquals("foobarbaz", is.exec(tf_.newTuple(strings)));
}
Also used : InvokeForString(com.twitter.elephantbird.pig.piggybank.InvokeForString) DataBag(org.apache.pig.data.DataBag) NonSpillableDataBag(org.apache.pig.data.NonSpillableDataBag) InvokeForInt(com.twitter.elephantbird.pig.piggybank.InvokeForInt) Test(org.junit.Test)

Example 2 with InvokeForInt

use of com.twitter.elephantbird.pig.piggybank.InvokeForInt in project elephant-bird by twitter.

the class TestInvoker method testIntInvoker.

@Test
public void testIntInvoker() throws SecurityException, ClassNotFoundException, NoSuchMethodException, NumberFormatException, IOException {
    InvokeForInt il = new InvokeForInt("java.lang.Integer.valueOf", "String");
    Tuple t = tf_.newTuple(1);
    String arg = "245";
    t.set(0, arg);
    assertEquals(Integer.valueOf(arg), il.exec(t));
}
Also used : InvokeForInt(com.twitter.elephantbird.pig.piggybank.InvokeForInt) InvokeForString(com.twitter.elephantbird.pig.piggybank.InvokeForString) Tuple(org.apache.pig.data.Tuple) Test(org.junit.Test)

Example 3 with InvokeForInt

use of com.twitter.elephantbird.pig.piggybank.InvokeForInt in project elephant-bird by twitter.

the class TestInvoker method testNoArgInvoker.

@Test
public void testNoArgInvoker() throws SecurityException, ClassNotFoundException, NoSuchMethodException, IOException {
    InvokeForInt id = new InvokeForInt(TestInvoker.class.getName() + ".simpleStaticFunction");
    assertEquals(Integer.valueOf(1), id.exec(tf_.newTuple()));
}
Also used : InvokeForInt(com.twitter.elephantbird.pig.piggybank.InvokeForInt) Test(org.junit.Test)

Aggregations

InvokeForInt (com.twitter.elephantbird.pig.piggybank.InvokeForInt)3 Test (org.junit.Test)3 InvokeForString (com.twitter.elephantbird.pig.piggybank.InvokeForString)2 DataBag (org.apache.pig.data.DataBag)1 NonSpillableDataBag (org.apache.pig.data.NonSpillableDataBag)1 Tuple (org.apache.pig.data.Tuple)1