Package org.apache.pig.data

Examples of org.apache.pig.data.Tuple.arity()


        // (while synthesizing individual fields, try to match fields that exist in the real data)
        for (Iterator<Tuple> it = outputConstraints.iterator(); it.hasNext(); ) {
            Tuple outputConstraint = it.next();
           
            // sanity check:
            if (outputConstraint.arity() != schema.numFields()) throw new RuntimeException("Internal error: incorrect number of fields in constraint tuple.");
           
            Tuple inputT = new Tuple(outputConstraint.arity());
            ExampleTuple inputTuple = new ExampleTuple();
            inputTuple.copyFrom(inputT);
            for (int i = 0; i < inputTuple.arity(); i++) {
View Full Code Here


    // what predicate it wants satisfied in a given field)
    //
    static Tuple GenerateMatchingTuple(Tuple constraint, Cond predicate) throws IOException {
        // first make a copy of the constraint tuple, since we will be modifying it
        Tuple t = new Tuple(constraint.arity());
        for (int i = 0; i < t.arity(); i++) t.setField(i, constraint.getField(i));
       
        // run best-effort attempt at filling in tuple's "don't care" values (i.e. nulls) in order to satisfy predicate
        GenerateMatchingTupleHelper(t, predicate, false);
       
        // test whether the outcome does indeed satisfy the predicate
View Full Code Here

        LoadFunc p1 = new PigStorage(":");
        FakeFSInputStream ffis1 = new FakeFSInputStream(input1.getBytes());
        p1.bindTo(null, new BufferedPositionedInputStream(ffis1), 0, input1.getBytes().length);
        Tuple f1 = p1.getNext();
        assertTrue(f1.arity() == arity1);

        LoadFunc p15 = new PigStorage();
        StringBuilder sb = new StringBuilder();
        int LOOP_COUNT = 1024;
        for (int i = 0; i < LOOP_COUNT; i++) {
View Full Code Here

        while (true) {
            Tuple f15 = p15.getNext();
            if (f15 == null)
                break;
            count++;
            assertEquals(3, f15.arity());
        }
        assertEquals(LOOP_COUNT * LOOP_COUNT, count);

        String input2 = ":this:has:a:leading:colon\n";
        int arity2 = 6;
View Full Code Here

        LoadFunc p2 = new PigStorage(":");
        FakeFSInputStream ffis2 = new FakeFSInputStream(input2.getBytes());
        p2.bindTo(null, new BufferedPositionedInputStream(ffis2), 0, input2.getBytes().length);
        Tuple f2 = p2.getNext();
        assertTrue(f2.arity() == arity2);

        String input3 = "this:has:a:trailing:colon:\n";
        int arity3 = 6;

        LoadFunc p3 = new PigStorage(":");
View Full Code Here

        LoadFunc p3 = new PigStorage(":");
        FakeFSInputStream ffis3 = new FakeFSInputStream(input3.getBytes());
        p3.bindTo(null, new BufferedPositionedInputStream(ffis3), 0, input1.getBytes().length);
        Tuple f3 = p3.getNext();
        assertTrue(f3.arity() == arity3);
    }

    /*
    @Test
    public void testLFBin() throws Exception {
View Full Code Here

        for (Iterator<Tuple> it = output.iterator(); it.hasNext(); ) {
            Tuple group = it.next();
           
            boolean isAcceptable;
           
            if (group.arity() == 2) {     // for single-relation group-by, need a group with at least 2 tuples
                isAcceptable = (group.getBagField(1).cardinality() >= 2);
            } else {                      // for co-group, need a group with at least one tuple from each input relation
                isAcceptable = true;
                for (int field = 1; field < group.arity(); field++) {
                    DataBag bag = group.getBagField(field);
View Full Code Here

           
            if (group.arity() == 2) {     // for single-relation group-by, need a group with at least 2 tuples
                isAcceptable = (group.getBagField(1).cardinality() >= 2);
            } else {                      // for co-group, need a group with at least one tuple from each input relation
                isAcceptable = true;
                for (int field = 1; field < group.arity(); field++) {
                    DataBag bag = group.getBagField(field);
                    if (bag.cardinality() == 0) {
                        isAcceptable = false;
                        break;
                    }
View Full Code Here

                //is tuple containing sum_x,sum_y,sum_x_y, sum_x_square, sum_y_square
                //and second is number of tuples from which it is calculated .
                //So if arity of combined is n then total number of schemas would be
                //root of x*x - x - n =0
                int totalSchemas=2;
                while(totalSchemas*(totalSchemas-1)<combined.arity()){
                    totalSchemas++;
                }
                //int totalSchemas = Double.valueOf(((1+Math.sqrt(1+4*combined.arity()))/2)).intValue();
               
                for(int i=0;i<totalSchemas;i++){
View Full Code Here

            //for each pair of input schema combined contain 2 member. first member
            //is tuple containing sum_x,sum_y,sum_x_y and second is number of tuples
            //from which it is calculated . So if arity of combined is n then total
            //number of schemas would be root of x*x - x - n =0
            int totalSchemas=2;
            while(totalSchemas*(totalSchemas-1)<combined.arity()){
                totalSchemas++;
            }
            //int totalSchemas = Double.valueOf(((1+Math.sqrt(1+4*combined.arity()))/2)).intValue();
           
            for(int i=0;i<totalSchemas;i++){
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.