Package org.apache.pig.data

Examples of org.apache.pig.data.DataAtom


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

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

        double actual = (new Double(output.strval())).doubleValue();

        assertTrue(actual == expected);
    }
View Full Code Here


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

        EvalFunc<DataAtom> sum = new SUM.Final();
        DataAtom output = new DataAtom();
        sum.exec(tup, output);

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

    public void testMIN() throws Exception {
        int input[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

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

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

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

        EvalFunc<DataAtom> min = new MIN.Final();
        DataAtom output = new DataAtom();
        min.exec(tup, output);

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

    public void testMAX() throws Exception {
        int input[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

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

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

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

        EvalFunc<DataAtom> max = new MAX.Final();
        DataAtom output = new DataAtom();
        max.exec(tup, output);

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

            result.setField(1, sum_x);
            result.setField(2, sum_y);
            result.setField(3, sum_x_square);
            result.setField(4, sum_y_square);
            output.appendField(result);
            output.appendField(new DataAtom(count));
        }
      
    }
View Full Code Here

            for(int i=0;i<input.arity();i++){
                for(int j=i+1;j<input.arity();j++){
                    DataBag first = input.getBagField(i);
                    DataBag second = input.getBagField(j);
                    output.appendField(computeAll(first, second));
                    output.appendField(new DataAtom(first.size()));
                   
                }
            }
           
            } catch(RuntimeException t) {
View Full Code Here

            Tuple result = new Tuple(3);
            result.setField(0, sum_x_y);
            result.setField(1, sum_x);
            result.setField(2, sum_y);
            output.appendField(result);
            output.appendField(new DataAtom(count));
        }
       
       
    }
View Full Code Here

        }
    }
    static public class MyGroup extends EvalFunc<Tuple> {
        @Override
        public void exec(Tuple input, Tuple output) throws IOException{
            output.appendField(new DataAtom("g"));
        }
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.