Package org.apache.pig.impl.plan

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


        String query = "c = union (load 'a' as (url, hitcount)), (load 'b');";
        LogicalPlan lp = planTester.buildPlan(query);

        //check that the loads' projection map is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        ProjectionMap loadaProjectionMap = loada.getProjectionMap();
        assertTrue(loadaProjectionMap.changes() == false);
       
        LOLoad loadb = (LOLoad) lp.getRoots().get(1);
        ProjectionMap loadbProjectionMap = loadb.getProjectionMap();
        assertTrue(loadbProjectionMap.changes() == false);
       
        //check union projection map
        LOUnion union = (LOUnion)lp.getSuccessors(loada).get(0);
        ProjectionMap unionProjectionMap = union.getProjectionMap();
        assertTrue(unionProjectionMap == null);
    }
View Full Code Here


        String query = "c = join (load 'a' as (url, hitcount)) by $0, (load 'b') by $0 using \"replicated\";";
        LogicalPlan lp = planTester.buildPlan(query);

        //check that the loads' projection map is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        ProjectionMap loadaProjectionMap = loada.getProjectionMap();
        assertTrue(loadaProjectionMap.changes() == false);
       
        LOLoad loadb = (LOLoad) lp.getRoots().get(1);
        ProjectionMap loadbProjectionMap = loadb.getProjectionMap();
        assertTrue(loadbProjectionMap.changes() == false);
       
        //check frjoin projection map
        LOJoin frjoin = (LOJoin)lp.getSuccessors(loada).get(0);
        ProjectionMap frjoinProjectionMap = frjoin.getProjectionMap();
        assertTrue(frjoinProjectionMap == null);
       
    }
View Full Code Here

        String query = "c = join (load 'a' as (url, hitcount)) by $0, (load 'b') by $0;";
        LogicalPlan lp = planTester.buildPlan(query);

        //check that the loads' projection map is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        ProjectionMap loadaProjectionMap = loada.getProjectionMap();
        assertTrue(loadaProjectionMap.changes() == false);
       
        LOLoad loadb = (LOLoad) lp.getRoots().get(1);
        ProjectionMap loadbProjectionMap = loadb.getProjectionMap();
        assertTrue(loadbProjectionMap.changes() == false);
       
        //check join projection map
        LOJoin join = (LOJoin)lp.getSuccessors(loada).get(0);
        ProjectionMap joinProjectionMap = join.getProjectionMap();
        assertTrue(joinProjectionMap == null);
    }
View Full Code Here

        String query = "foreach (cogroup (load 'a') by ($1), (load 'b') by ($1)) generate $1.$1, $2.$1 ;";
        LogicalPlan lp = planTester.buildPlan(query);
       
        //check that the loads' projection map is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        ProjectionMap loadaProjectionMap = loada.getProjectionMap();
        assertTrue(loadaProjectionMap.changes() == false);
       
        LOLoad loadb = (LOLoad) lp.getRoots().get(1);
        ProjectionMap loadbProjectionMap = loadb.getProjectionMap();
        assertTrue(loadbProjectionMap.changes() == false);

        //check cogroup projection map
        LOCogroup cogroup = (LOCogroup)lp.getSuccessors(loada).get(0);
        ProjectionMap cogroupProjectionMap = cogroup.getProjectionMap();
        assertTrue(cogroupProjectionMap.changes() == true);
       
        MultiMap<Integer, ProjectionMap.Column> cogroupMapFields = cogroupProjectionMap.getMappedFields();
        assertTrue(cogroupMapFields != null);
       
        List<ProjectionMap.Column> mapValues = (ArrayList<ProjectionMap.Column>)cogroupMapFields.get(0);
        assertTrue(mapValues.get(0).getInputColumn().first == 0);
        assertTrue(mapValues.get(0).getInputColumn().second == 1);
        assertTrue(mapValues.get(1).getInputColumn().first == 1);
        assertTrue(mapValues.get(1).getInputColumn().second == 1);
       
        //check the cogroup removed fields is null
        assertTrue(cogroupProjectionMap.getRemovedFields() == null);
       
        //check that cogroup added fields contain [1, 2]
        List<Integer> cogroupAddedFields = cogroupProjectionMap.getAddedFields();
        assertTrue(cogroupAddedFields.size() == 2);
        assertTrue(cogroupAddedFields.get(0) == 1);
        assertTrue(cogroupAddedFields.get(1) == 2);
       
        //check that the foreach projection map has null mappedFields
        LOForEach foreach = (LOForEach)lp.getLeaves().get(0);
        ProjectionMap foreachProjectionMap = foreach.getProjectionMap();
        assertTrue(foreachProjectionMap.changes() == true);
       
        MultiMap<Integer, ProjectionMap.Column> foreachMapFields = foreachProjectionMap.getMappedFields();
        assertTrue(foreachMapFields != null);
       
        mapValues = (ArrayList<ProjectionMap.Column>)foreachMapFields.get(0);
        assertTrue(mapValues.get(0).getInputColumn().first == 0);
        assertTrue(mapValues.get(0).getInputColumn().second == 1);
       
        mapValues = (ArrayList<ProjectionMap.Column>)foreachMapFields.get(1);
        assertTrue(mapValues.get(0).getInputColumn().first == 0);
        assertTrue(mapValues.get(0).getInputColumn().second == 2);

        //check that removed fields has all the group column from the input cogroup
        List<Pair<Integer, Integer>> foreachRemovedFields = foreachProjectionMap.getRemovedFields();
        assertTrue(foreachRemovedFields.size() == 1);
        Pair<Integer, Integer> removedField = foreachRemovedFields.get(0);
        assertTrue(removedField.first == 0);
        assertTrue(removedField.second == 0);
       
        //check that added fields is null
        List<Integer> foreachAddedFields = foreachProjectionMap.getAddedFields();
        assertTrue(foreachAddedFields == null);
    }
View Full Code Here

        String query = "foreach (group (load 'a') by ($6, $7)) generate flatten(group) ;";
        LogicalPlan lp = planTester.buildPlan(query);
       
        //check that the loads' projection map is null
        LOLoad loada = (LOLoad) lp.getRoots().get(0);
        ProjectionMap loadaProjectionMap = loada.getProjectionMap();
        assertTrue(loadaProjectionMap.changes() == false);
       
        //check cogroup projection map
        LOCogroup cogroup = (LOCogroup)lp.getSuccessors(loada).get(0);
        ProjectionMap cogroupProjectionMap = cogroup.getProjectionMap();
        assertTrue(cogroupProjectionMap.changes() == true);

        MultiMap<Integer, ProjectionMap.Column> cogroupMapFields = cogroupProjectionMap.getMappedFields();
        assertTrue(cogroupMapFields != null);
       
        List<ProjectionMap.Column> mapValues = (ArrayList<ProjectionMap.Column>)cogroupMapFields.get(0);
        assertTrue(mapValues.get(0).getInputColumn().first == 0);
        assertTrue(mapValues.get(0).getInputColumn().second == 6);
        assertTrue(mapValues.get(1).getInputColumn().first == 0);
        assertTrue(mapValues.get(1).getInputColumn().second == 7);
       
        //check the cogroup removed fields is null
        assertTrue(cogroupProjectionMap.getRemovedFields() == null);
       
        //check that cogroup added fields contain [1, 2]
        List<Integer> cogroupAddedFields = cogroupProjectionMap.getAddedFields();
        assertTrue(cogroupAddedFields.size() == 1);
        assertTrue(cogroupAddedFields.get(0) == 1);
       
        //check that the foreach projection map has null mappedFields
        LOForEach foreach = (LOForEach)lp.getLeaves().get(0);
        ProjectionMap foreachProjectionMap = foreach.getProjectionMap();
        assertTrue(foreachProjectionMap.changes() == true);
       
        MultiMap<Integer, ProjectionMap.Column> foreachMapFields = foreachProjectionMap.getMappedFields();
        assertTrue(foreachMapFields != null);
       
        mapValues = (ArrayList<ProjectionMap.Column>)foreachMapFields.get(0);
        assertTrue(mapValues.get(0).getInputColumn().first == 0);
        assertTrue(mapValues.get(0).getInputColumn().second == 0);
       
        mapValues = (ArrayList<ProjectionMap.Column>)foreachMapFields.get(1);
        assertTrue(mapValues.get(0).getInputColumn().first == 0);
        assertTrue(mapValues.get(0).getInputColumn().second == 0);

        //check that removed fields has all the group column from the input cogroup
        List<Pair<Integer, Integer>> foreachRemovedFields = foreachProjectionMap.getRemovedFields();
        assertTrue(foreachRemovedFields.size() == 1);
        Pair<Integer, Integer> removedField = foreachRemovedFields.get(0);
        assertTrue(removedField.first == 0);
        assertTrue(removedField.second == 1);
       
        //check that added fields is null
        List<Integer> foreachAddedFields = foreachProjectionMap.getAddedFields();
        assertTrue(foreachAddedFields == null);

    }
View Full Code Here

        planTester.buildPlan("a = load 'a';");
        LogicalPlan lp = planTester.buildPlan("b = filter a by $1 == '3';");
       
        //check that the load projection map is null
        LOLoad load = (LOLoad) lp.getRoots().get(0);
        ProjectionMap loadProjectionMap = load.getProjectionMap();
        assertTrue(loadProjectionMap.changes() == false);
       
        //check that the filter projection map has null mappedFields
        LOFilter filter = (LOFilter)lp.getLeaves().get(0);
        ProjectionMap filterProjectionMap = filter.getProjectionMap();
        assertTrue(filterProjectionMap.changes() == false);
    }
View Full Code Here

        planTester.buildPlan("a = load 'a';");
        LogicalPlan lp = planTester.buildPlan("split a into b if $0 == '3', c if $1 == '3';");
       
        //check that the load projection map is null
        LOLoad load = (LOLoad) lp.getRoots().get(0);
        ProjectionMap loadProjectionMap = load.getProjectionMap();
        assertTrue(loadProjectionMap.changes() == false);
       
        //check that the split projection map has null mappedFields
        LOSplit split = (LOSplit)lp.getSuccessors(load).get(0);
        ProjectionMap splitProjectionMap = split.getProjectionMap();
        assertTrue(splitProjectionMap.changes() == false);
       
        LOSplitOutput splitb = (LOSplitOutput)lp.getSuccessors(split).get(0);
        ProjectionMap splitbProjectionMap = splitb.getProjectionMap();
        assertTrue(splitbProjectionMap.changes() == false);
       
        LOSplitOutput splitc = (LOSplitOutput)lp.getSuccessors(split).get(1);
        ProjectionMap splitcProjectionMap = splitc.getProjectionMap();
        assertTrue(splitcProjectionMap.changes() == false);
    }
View Full Code Here

        planTester.buildPlan("a = load 'a';");
        LogicalPlan lp = planTester.buildPlan("b = order a by $1;");
       
        //check that the load projection map is null
        LOLoad load = (LOLoad) lp.getRoots().get(0);
        ProjectionMap loadProjectionMap = load.getProjectionMap();
        assertTrue(loadProjectionMap.changes() == false);
       
        //check that the order by projection map has null mappedFields
        LOSort sort = (LOSort)lp.getLeaves().get(0);
        ProjectionMap sortProjectionMap = sort.getProjectionMap();
        assertTrue(sortProjectionMap.changes() == false);
    }
View Full Code Here

        planTester.buildPlan("b = order a by $1;");
        LogicalPlan lp = planTester.buildPlan("c = limit b 10;");
       
        //check that the load projection map is null
        LOLoad load = (LOLoad) lp.getRoots().get(0);
        ProjectionMap loadProjectionMap = load.getProjectionMap();
        assertTrue(loadProjectionMap.changes() == false);
       
        //check that the order by projection map is not null
        LOSort sort = (LOSort)lp.getSuccessors(load).get(0);
        ProjectionMap sortProjectionMap = sort.getProjectionMap();
        assertTrue(sortProjectionMap.changes() == false);
       
        //check that the limit projection map is null
        LOLimit limit = (LOLimit)lp.getLeaves().get(0);
        ProjectionMap limitProjectionMap = limit.getProjectionMap();
        assertTrue(limitProjectionMap.changes() == false);
    }
View Full Code Here

        planTester.buildPlan("a = load 'a';");
        LogicalPlan lp = planTester.buildPlan("b = distinct a;");
       
        //check that the load projection map is null
        LOLoad load = (LOLoad) lp.getRoots().get(0);
        ProjectionMap loadProjectionMap = load.getProjectionMap();
        assertTrue(loadProjectionMap.changes() == false);
       
        //check that the distinct projection map has null mappedFields
        LODistinct distinct = (LODistinct)lp.getLeaves().get(0);
        ProjectionMap distinctProjectionMap = distinct.getProjectionMap();
        assertTrue(distinctProjectionMap.changes() == false);
    }
View Full Code Here

TOP

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

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.