Package org.apache.pig.impl.plan

Examples of org.apache.pig.impl.plan.RequiredFields


        //check that the loads' required fields is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        List<RequiredFields> loadaRequiredFields = loada.getRequiredFields();
        assertTrue(loadaRequiredFields.size() == 1);
       
        RequiredFields requiredField = loadaRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

        LOLoad loadb = (LOLoad) lp.getRoots().get(1);
        List<RequiredFields> loadbRequiredFields = loadb.getRequiredFields();
        assertTrue(loadbRequiredFields.size() == 1);
       
        requiredField = loadbRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

        //check cogroup required fields
        LOCogroup cogroup = (LOCogroup)lp.getSuccessors(loada).get(0);
        List<RequiredFields> cogroupRequiredFields = cogroup.getRequiredFields();
        assertTrue(cogroupRequiredFields.size() == 2);
       
        requiredField = cogroupRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == false);
        assertTrue(requiredField.needAllFields() == false);

        List<Pair<Integer, Integer>> fields = requiredField.getFields();
        assertTrue(fields.size() == 1);
        assertTrue(fields.get(0).first == 0);
        assertTrue(fields.get(0).second == 1);
       
        requiredField = cogroupRequiredFields.get(1);
        assertTrue(requiredField.needNoFields() == false);
        assertTrue(requiredField.needAllFields() == false);

        fields = requiredField.getFields();
        assertTrue(fields.size() == 1);
        assertTrue(fields.get(0).first == 1);
        assertTrue(fields.get(0).second == 1);
       
        //check that the foreach required fields contain [<0, 1>, <0, 2>]
        LOForEach foreach = (LOForEach)lp.getLeaves().get(0);
        List<RequiredFields> foreachRequiredFields = foreach.getRequiredFields();
        assertTrue(foreachRequiredFields.size() == 1);
       
        requiredField = foreachRequiredFields.get(0);
        fields = requiredField.getFields();
        assertTrue(fields.size() == 2);
        assertTrue(fields.get(0).first == 0);
        assertTrue(fields.get(0).second == 1);
        assertTrue(fields.get(1).first == 0);
        assertTrue(fields.get(1).second == 2);
View Full Code Here


        //check that the loads' required fields is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        List<RequiredFields> loadaRequiredFields = loada.getRequiredFields();
        assertTrue(loadaRequiredFields.size() == 1);
       
        RequiredFields requiredField = loadaRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

        LOLoad loadb = (LOLoad) lp.getRoots().get(1);
        List<RequiredFields> loadbRequiredFields = loadb.getRequiredFields();
        assertTrue(loadbRequiredFields.size() == 1);
       
        requiredField = loadbRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

        //check cross required fields
        LOCross cross = (LOCross)lp.getSuccessors(loada).get(0);
        List<RequiredFields> crossRequiredFields = cross.getRequiredFields();
        assertTrue(crossRequiredFields.size() == 2);
       
        requiredField = crossRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == false);
        assertTrue(requiredField.needAllFields() == true);
        assertTrue(requiredField.getFields() == null);

        requiredField = crossRequiredFields.get(1);
        assertTrue(requiredField.needNoFields() == false);
        assertTrue(requiredField.needAllFields() == true);
        assertTrue(requiredField.getFields() == null);
       
    }
View Full Code Here

        //check that the loads' required fields is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        List<RequiredFields> loadaRequiredFields = loada.getRequiredFields();
        assertTrue(loadaRequiredFields.size() == 1);
       
        RequiredFields requiredField = loadaRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

        LOLoad loadb = (LOLoad) lp.getRoots().get(1);
        List<RequiredFields> loadbRequiredFields = loadb.getRequiredFields();
        assertTrue(loadbRequiredFields.size() == 1);
       
        requiredField = loadbRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

        //check union required fields
        LOUnion union = (LOUnion)lp.getSuccessors(loada).get(0);
        List<RequiredFields> unionRequiredFields = union.getRequiredFields();
        assertTrue(unionRequiredFields.size() == 2);
       
        requiredField = unionRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == false);
        assertTrue(requiredField.needAllFields() == true);
        assertTrue(requiredField.getFields() == null);

        requiredField = unionRequiredFields.get(1);
        assertTrue(requiredField.needNoFields() == false);
        assertTrue(requiredField.needAllFields() == true);
        assertTrue(requiredField.getFields() == null);
       
    }
View Full Code Here

        //check that the loads' required fields is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        List<RequiredFields> loadaRequiredFields = loada.getRequiredFields();
        assertTrue(loadaRequiredFields.size() == 1);
       
        RequiredFields requiredField = loadaRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

        LOLoad loadb = (LOLoad) lp.getRoots().get(1);
        List<RequiredFields> loadbRequiredFields = loadb.getRequiredFields();
        assertTrue(loadbRequiredFields.size() == 1);
       
        requiredField = loadbRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

        //check frjoin required fields
        LOJoin frjoin = (LOJoin)lp.getSuccessors(loada).get(0);
        List<RequiredFields> frjoinRequiredFields = frjoin.getRequiredFields();
        assertTrue(frjoinRequiredFields.size() == 2);
       
        requiredField = frjoinRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == false);
        assertTrue(requiredField.needAllFields() == false);

        List<Pair<Integer, Integer>> fields = requiredField.getFields();
        assertTrue(fields.size() == 1);
        assertTrue(fields.get(0).first == 0);
        assertTrue(fields.get(0).second == 0);


        requiredField = frjoinRequiredFields.get(1);
        assertTrue(requiredField.needNoFields() == false);
        assertTrue(requiredField.needAllFields() == false);
       
        fields = requiredField.getFields();
        assertTrue(fields.size() == 1);
        assertTrue(fields.get(0).first == 1);
        assertTrue(fields.get(0).second == 0);
    }
View Full Code Here

        //check that the loads' required fields is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        List<RequiredFields> loadaRequiredFields = loada.getRequiredFields();
        assertTrue(loadaRequiredFields.size() == 1);
       
        RequiredFields requiredField = loadaRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

        LOLoad loadb = (LOLoad) lp.getRoots().get(1);
        List<RequiredFields> loadbRequiredFields = loadb.getRequiredFields();
        assertTrue(loadbRequiredFields.size() == 1);
       
        requiredField = loadbRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

        //check join required fields
        LOJoin join = (LOJoin)lp.getSuccessors(loada).get(0);
        List<RequiredFields> joinRequiredFields = join.getRequiredFields();
        assertTrue(joinRequiredFields.size() == 2);
       
        requiredField = joinRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == false);
        assertTrue(requiredField.needAllFields() == false);

        List<Pair<Integer, Integer>> fields = requiredField.getFields();
        assertTrue(fields.size() == 1);
        assertTrue(fields.get(0).first == 0);
        assertTrue(fields.get(0).second == 0);


        requiredField = joinRequiredFields.get(1);
        assertTrue(requiredField.needNoFields() == false);
        assertTrue(requiredField.needAllFields() == false);
       
        fields = requiredField.getFields();
        assertTrue(fields.size() == 1);
        assertTrue(fields.get(0).first == 1);
        assertTrue(fields.get(0).second == 0);

    }
View Full Code Here

        //check that the load's required fields is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        List<RequiredFields> loadaRequiredFields = loada.getRequiredFields();
        assertTrue(loadaRequiredFields.size() == 1);
       
        RequiredFields requiredField = loadaRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

       
        //check filter required fields
        LOFilter filter = (LOFilter)lp.getSuccessors(loada).get(0);
        List<RequiredFields> filterRequiredFields = filter.getRequiredFields();
        assertTrue(filterRequiredFields.size() == 1);
       
        requiredField = filterRequiredFields.get(0);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.needNoFields() == false);
       
        List<Pair<Integer, Integer>> fields = requiredField.getFields();
        assertTrue(fields.size() == 1);
        assertTrue(fields.get(0).first == 0);
        assertTrue(fields.get(0).second == 1);
    }
View Full Code Here

        //check that the load's required fields is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        List<RequiredFields> loadaRequiredFields = loada.getRequiredFields();
        assertTrue(loadaRequiredFields.size() == 1);
       
        RequiredFields requiredField = loadaRequiredFields.get(0);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.getFields() == null);

        LOSplit split = (LOSplit)lp.getSuccessors(loada).get(0);
        List<RequiredFields> splitRequiredFields = split.getRequiredFields();
        assertTrue(splitRequiredFields.size() == 1);
       
        requiredField = splitRequiredFields.get(0);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.needNoFields() == true);
        assertTrue(requiredField.getFields() == null);
       
        //check split outputs' required fields
        LOSplitOutput splitb = (LOSplitOutput)lp.getSuccessors(split).get(0);
        List<RequiredFields> splitbRequiredFields = splitb.getRequiredFields();
        assertTrue(splitbRequiredFields.size() == 1);
       
        requiredField = splitbRequiredFields.get(0);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.needNoFields() == false);
       
        List<Pair<Integer, Integer>> fields = requiredField.getFields();
        assertTrue(fields.size() == 1);
        assertTrue(fields.get(0).first == 0);
        assertTrue(fields.get(0).second == 0);
       
        LOSplitOutput splitc = (LOSplitOutput)lp.getSuccessors(split).get(1);
        List<RequiredFields> splitcRequiredFields = splitc.getRequiredFields();
        assertTrue(splitcRequiredFields.size() == 1);
       
        requiredField = splitcRequiredFields.get(0);
        assertTrue(requiredField.needAllFields() == false);
        assertTrue(requiredField.needNoFields() == false);
       
        fields = requiredField.getFields();
        assertTrue(fields.size() == 1);
        assertTrue(fields.get(0).first == 0);
        assertTrue(fields.get(0).second == 1);
    }
View Full Code Here

    public void testQueryUnionNoSchema() throws FrontendException {
        String query = "c = union (load 'a'), (load 'b');";
        LogicalPlan lp = planTester.buildPlan(query);

        LOUnion union = (LOUnion)lp.getLeaves().get(0);
        RequiredFields unionRelevantFields0 = union.getRelevantInputs(0, 0).get(0);
        assertTrue(unionRelevantFields0.getNeedAllFields() == false);
        assertTrue(unionRelevantFields0.getNeedNoFields() == false);
        assertTrue(unionRelevantFields0.getFields().size() == 1);
        assertTrue(unionRelevantFields0.getFields().contains(new Pair<Integer, Integer>(0, 0)));
       
        RequiredFields unionRelevantFields1 = union.getRelevantInputs(0, 0).get(1);
        assertTrue(unionRelevantFields1.getNeedAllFields() == false);
        assertTrue(unionRelevantFields1.getNeedNoFields() == false);
        assertTrue(unionRelevantFields1.getFields().size() == 1);
        assertTrue(unionRelevantFields1.getFields().contains(new Pair<Integer, Integer>(1, 0)));
    }
View Full Code Here

    public void testQuerySplitWithSchema() throws FrontendException {
        planTester.buildPlan("a = load 'a' as (url, hitCount);");
        LogicalPlan lp = planTester.buildPlan("split a into b if url == '3', c if hitCount == '3';");
       
        LOSplit split = (LOSplit)lp.getSuccessors(lp.getRoots().get(0)).get(0);
        RequiredFields splitRelevantFields0 = split.getRelevantInputs(0, 0).get(0);
        assertTrue(splitRelevantFields0.needAllFields() == false);
        assertTrue(splitRelevantFields0.needNoFields() == false);
        assertTrue(splitRelevantFields0.getFields().size() == 1);
        assertTrue(splitRelevantFields0.getFields().contains(new Pair<Integer, Integer>(0, 0)));
       
        RequiredFields splitRelevantFields1 = split.getRelevantInputs(0, 1).get(0);
        assertTrue(splitRelevantFields1.needAllFields() == false);
        assertTrue(splitRelevantFields1.needNoFields() == false);
        assertTrue(splitRelevantFields1.getFields().size() == 1);
        assertTrue(splitRelevantFields1.getFields().contains(new Pair<Integer, Integer>(0, 1)));

        assertTrue(split.getRelevantInputs(0, 2) == null);

        LOSplitOutput splitb = (LOSplitOutput)lp.getSuccessors(split).get(0);
        RequiredFields splitbRelevantFields = splitb.getRelevantInputs(0, 1).get(0);
        assertTrue(splitbRelevantFields.getNeedAllFields() == false);
        assertTrue(splitbRelevantFields.getNeedNoFields() == false);
        assertTrue(splitbRelevantFields.getFields().size() == 1);
        assertTrue(splitbRelevantFields.getFields().contains(new Pair<Integer, Integer>(0, 1)));
       
        LOSplitOutput splitc = (LOSplitOutput)lp.getSuccessors(split).get(0);
        RequiredFields splitcRelevantFields = splitc.getRelevantInputs(0, 1).get(0);
        assertTrue(splitcRelevantFields.getNeedAllFields() == false);
        assertTrue(splitcRelevantFields.getNeedNoFields() == false);
        assertTrue(splitcRelevantFields.getFields().size() == 1);
        assertTrue(splitcRelevantFields.getFields().contains(new Pair<Integer, Integer>(0, 1)));
    }
View Full Code Here

    public void testQueryOrderByWithSchema() throws FrontendException {
        planTester.buildPlan("a = load 'a' as (url,hitCount);");
        LogicalPlan lp = planTester.buildPlan("b = order a by $1;");
       
        LOSort sort = (LOSort)lp.getSuccessors(lp.getRoots().get(0)).get(0);
        RequiredFields sortRelevantFields0 = sort.getRelevantInputs(0, 0).get(0);
        assertTrue(sortRelevantFields0.getNeedAllFields() == false);
        assertTrue(sortRelevantFields0.getNeedNoFields() == false);
        assertTrue(sortRelevantFields0.getFields().size() == 1);
        assertTrue(sortRelevantFields0.getFields().contains(new Pair<Integer, Integer>(0, 0)));
       
        RequiredFields sortRelevantFields1 = sort.getRelevantInputs(0, 1).get(0);
        assertTrue(sortRelevantFields1.getNeedAllFields() == false);
        assertTrue(sortRelevantFields1.getNeedNoFields() == false);
        assertTrue(sortRelevantFields1.getFields().size() == 1);
        assertTrue(sortRelevantFields1.getFields().contains(new Pair<Integer, Integer>(0, 1)));
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.plan.RequiredFields

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.