Package org.apache.pig.data

Examples of org.apache.pig.data.DataAtom


    }

    static public class Initial extends EvalFunc<Tuple> {
        @Override
        public void exec(Tuple input, Tuple output) throws IOException {
            output.appendField(new DataAtom(sum(input)));
        }
View Full Code Here


    }

    static public class Initial extends EvalFunc<Tuple> {
        @Override
        public void exec(Tuple input, Tuple output) throws IOException {
            output.appendField(new DataAtom(count(input)));
        }
View Full Code Here

    }

    static public class Intermed extends EvalFunc<Tuple> {
        @Override
        public void exec(Tuple input, Tuple output) throws IOException {
            output.appendField(new DataAtom(sum(input)));
        }
View Full Code Here

           
            sum += t.getAtomField(0).numval();
            count += t.getAtomField(1).numval();
        }

        output.appendField(new DataAtom(sum));
        output.appendField(new DataAtom(count));
    }
View Full Code Here

    static public class Initial extends EvalFunc<Tuple> {
        @Override
        public void exec(Tuple input, Tuple output) throws IOException {
            try {
            output.appendField(new DataAtom(sum(input)));
            output.appendField(new DataAtom(count(input)));
            // output.appendField(new DataAtom("processed by initial"));
            } catch(RuntimeException t) {
                throw new RuntimeException(t.getMessage() + ": " + input, t);
            }
        }
View Full Code Here

        int input[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
        double expected = 5.5;

        EvalFunc<DataAtom> avg = new AVG();
        Tuple tup = Util.loadNestTuple(new Tuple(1), input);
        DataAtom output = new DataAtom();
        avg.exec(tup, output);
       
        double actual = (new Double(output.strval())).doubleValue();
        assertTrue(actual == expected);
    }
View Full Code Here

        bag.add(t3);
       
        Tuple tup = new Tuple(bag);

        EvalFunc<DataAtom> avg = new AVG.Final();
        DataAtom output = new DataAtom();
        avg.exec(tup, output);

        assertEquals("Expected average to be 4.852941176470588",
            4.852941176470588, output.numval());
    }
View Full Code Here

        int input[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
        double expected = input.length;

        EvalFunc<DataAtom> count = new COUNT();
        Tuple tup = Util.loadNestTuple(new Tuple(1), input);
        DataAtom output = new DataAtom();
        count.exec(tup, output);

        double actual = (new Double(output.strval())).doubleValue();
        assertTrue(actual == expected);
    }
View Full Code Here

    public void testCOUNTMap() throws Exception {
        DataMap map = new DataMap();
       
        Tuple tup = new Tuple();
        tup.appendField(map);
        DataAtom output = new DataAtom();
       
       
        EvalFunc<DataAtom> count = new COUNT();
        FilterFunc isEmpty = new IsEmpty();
       
        assertTrue(isEmpty.exec(tup));
        count.exec(tup,output);
        assertTrue(output.numval() == 0);
       
        map.put("a", new DataAtom("a"));

        assertFalse(isEmpty.exec(tup));
        count.exec(tup,output);
        assertTrue(output.numval() == 1);

       
        map.put("b", new Tuple());

        assertFalse(isEmpty.exec(tup));
        count.exec(tup,output);
        assertTrue(output.numval() == 2);
       
    }
View Full Code Here

    public void testCOUNTFinal() throws Exception {
        int input[] = { 23, 38, 39 };
        Tuple tup = Util.loadNestTuple(new Tuple(1), input);

        EvalFunc<DataAtom> count = new COUNT.Final();
        DataAtom output = new DataAtom();
        count.exec(tup, output);

        assertEquals("Expected count to be 100", 100, output.longVal());
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.data.DataAtom

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.