Package org.apache.pig.builtin

Examples of org.apache.pig.builtin.SPRINTF


        Integer ii  = 665568;
        Float   ff  = 993.14159265f;
        String  exp = "    665568 <meep  <    665,568 >   meep>    a27e0    993.142";
        Tuple   ts;
        String  res;
        EvalFunc<String> sprinter = new SPRINTF();
        //
        // Formats output, happily navigating strings, numbers, etc
        ts = TupleFactory.getInstance().newTuple(5);
        ts.set(0, fmt);
        ts.set(1, s1);
        ts.set(2, ii);
        ts.set(3, ff);
        ts.set(4, (long)(ii * 1000000L));
        res = sprinter.exec(ts);
        assertEquals(exp, res);
        //
        // Happy with float/double, int/long
        ts.set(2, 665568l);
        ts.set(3, 993.14159265d);
        res = sprinter.exec(ts);
        assertEquals(exp, res);
        //
        // Returns null if any input is null
        ts.set(3, null);
        res = sprinter.exec(ts);
        assertNull(res);
        ts.set(3, ff);
        ts.set(0, null);
        res = sprinter.exec(ts);
        assertNull(res);
        //
        // Works with just one arg
        ts = TupleFactory.getInstance().newTuple(1);
        ts.set(0, "meep!");
        res = sprinter.exec(ts);
        assertEquals("meep!", res);

        // Test in script
        //
        String input = "vararg_sprintf_test_jira_3939.txt";
View Full Code Here

TOP

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

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.