Package org.apache.pig.builtin

Examples of org.apache.pig.builtin.InvokeForString


    @Test
    public void testStringInvoker() throws SecurityException, ClassNotFoundException, NoSuchMethodException, IOException {

        // Test non-static method
        InvokeForString is = new InvokeForString("java.lang.String.toUpperCase", "String", "false");
        assertEquals("FOO", is.exec(tf_.newTuple("foo")));

        // both "static" and "true" should work
        // Test static method
        is = new InvokeForString("java.lang.String.valueOf", "int", "true");
        Tuple t = tf_.newTuple(1);
        t.set(0,231);
        assertEquals("231", is.exec(t));

        // test default (should be static)
        is = new InvokeForString("java.lang.String.valueOf", "int");
        assertEquals("231", is.exec(t));

        // Test method with multiple args
        is = new InvokeForString(TestInvoker.class.getName()+".concatStrings", "String String");
        t = tf_.newTuple(2);
        t.set(0, "foo");
        t.set(1, "bar");
        assertEquals("foobar", is.exec(t));
    }
View Full Code Here


     
      ii = new InvokeForInt(TestInvoker.class.getName() + ".avg", "long[]");
      nums = newSimpleBag(1L, 2L, 3L);
      assertEquals(Integer.valueOf(2), ii.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)));
    }
View Full Code Here

    @Test
    public void testStringInvoker() throws SecurityException, ClassNotFoundException, NoSuchMethodException, IOException {

        // Test non-static method
        InvokeForString is = new InvokeForString("java.lang.String.toUpperCase", "String", "false");
        assertEquals("FOO", is.exec(tf_.newTuple("foo")));

        // both "static" and "true" should work
        // Test static method
        is = new InvokeForString("java.lang.String.valueOf", "int", "true");
        Tuple t = tf_.newTuple(1);
        t.set(0,231);
        assertEquals("231", is.exec(t));

        // test default (should be static)
        is = new InvokeForString("java.lang.String.valueOf", "int");
        assertEquals("231", is.exec(t));

        // Test method with multiple args
        is = new InvokeForString(TestInvoker.class.getName()+".concatStrings", "String String");
        t = tf_.newTuple(2);
        t.set(0, "foo");
        t.set(1, "bar");
        assertEquals("foobar", is.exec(t));
    }
View Full Code Here

     
      ii = new InvokeForInt(TestInvoker.class.getName() + ".avg", "long[]");
      nums = newSimpleBag(1L, 2L, 3L);
      assertEquals(Integer.valueOf(2), ii.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)));
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.builtin.InvokeForString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.