Package org.apache.pig.impl.plan

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


        String query = "stream (load 'a') through `" + simpleEchoStreamingCommand + "`;";
        LogicalPlan lp = planTester.buildPlan(query);
       
        //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 stream projection map is null
        LOStream stream = (LOStream)lp.getLeaves().get(0);
        ProjectionMap streamProjectionMap = stream.getProjectionMap();
        assertTrue(streamProjectionMap == null);
    }
View Full Code Here


        String query = "stream (load 'a' as (url, hitCount)) through `" + simpleEchoStreamingCommand + "` ;";
        LogicalPlan lp = planTester.buildPlan(query);
       
        //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 stream projection map is null
        LOStream stream = (LOStream)lp.getLeaves().get(0);
        ProjectionMap streamProjectionMap = stream.getProjectionMap();
        assertTrue(streamProjectionMap == null);
    }
View Full Code Here

        String query = "foreach (load 'a') generate ($1 == '3'? $2 : $3) ;";
        LogicalPlan lp = planTester.buildPlan(query);
       
        //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 foreach projection map has null mappedFields
        //and null removed fields since the input schema is null
        LOForEach foreach = (LOForEach)lp.getLeaves().get(0);
        ProjectionMap foreachProjectionMap = foreach.getProjectionMap();
        assertTrue(foreachProjectionMap.changes() == true);
        assertTrue(foreachProjectionMap.getMappedFields() == null);
        assertTrue(foreachProjectionMap.getRemovedFields() == null);
       
        //check that added fields contain [0]
        List<Integer> foreachAddedFields = foreachProjectionMap.getAddedFields();
        assertTrue(foreachAddedFields.size() == 1);
        assertTrue(foreachAddedFields.get(0) == 0);
    }
View Full Code Here

        planTester.buildPlan("B = load 'b';");
        LogicalPlan lp = planTester.buildPlan("foreach (cogroup A by ($1), B by ($1)) generate A, flatten(B.($1, $2, $3));");
       
        //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> cogroupMapValues = (ArrayList<ProjectionMap.Column>)cogroupMapFields.get(0);
        assertTrue(cogroupMapValues.get(0).getInputColumn().first == 0);
        assertTrue(cogroupMapValues.get(0).getInputColumn().second == 1);
        assertTrue(cogroupMapValues.get(1).getInputColumn().first == 1);
        assertTrue(cogroupMapValues.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 non-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);
       
        List<ProjectionMap.Column> foreachMapValues = (ArrayList<ProjectionMap.Column>)foreachMapFields.get(0);
        assertTrue(foreachMapValues.get(0).getInputColumn().first == 0);
        assertTrue(foreachMapValues.get(0).getInputColumn().second == 1);
       
        for(int i = 1; i < 4; ++i) {
            foreachMapValues = (ArrayList<ProjectionMap.Column>)foreachMapFields.get(i);
            assertTrue(foreachMapValues.get(0).getInputColumn().first == 0);
            assertTrue(foreachMapValues.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(foreachProjectionMap.getRemovedFields().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

                "};" ;
        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> cogroupMapValues = (ArrayList<ProjectionMap.Column>)cogroupMapFields.get(0);
        assertTrue(cogroupMapValues.get(0).getInputColumn().first == 0);
        assertTrue(cogroupMapValues.get(0).getInputColumn().second == 1);
        assertTrue(cogroupMapValues.get(1).getInputColumn().first == 1);
        assertTrue(cogroupMapValues.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);
       
        List<ProjectionMap.Column> foreachMapValues = (ArrayList<ProjectionMap.Column>)foreachMapFields.get(0);
        assertTrue(foreachMapValues.get(0).getInputColumn().first == 0);
        assertTrue(foreachMapValues.get(0).getInputColumn().second == 1);
       
        //check that removed fields has all the columns from the input cogroup
        List<Pair<Integer, Integer>> foreachRemovedFields = foreachProjectionMap.getRemovedFields();
        assertTrue(foreachProjectionMap.getRemovedFields().size() == 2);
        Pair<Integer, Integer> removedField = foreachRemovedFields.get(0);
        assertTrue(removedField.first == 0);
        assertTrue(removedField.second == 0);
       
        removedField = foreachRemovedFields.get(1);
        assertTrue(removedField.first == 0);
        assertTrue(removedField.second == 2);

        //check that added fields contain [0]
        List<Integer> foreachAddedFields = foreachProjectionMap.getAddedFields();
        assertTrue(foreachAddedFields.size() == 1);
        assertTrue(foreachAddedFields.get(0) == 1);
    }
View Full Code Here

        String query = "c = cross (load 'a'), (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 cross projection map
        LOCross cross = (LOCross)lp.getSuccessors(loada).get(0);
        ProjectionMap crossProjectionMap = cross.getProjectionMap();
        assertTrue(crossProjectionMap == null);
       
    }
View Full Code Here

        String query = "c = union (load 'a'), (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') 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') 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

        planTester.buildPlan("a = load 'a' as (url,hitCount);");
        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 is not null
        LOFilter filter = (LOFilter)lp.getLeaves().get(0);
        ProjectionMap filterProjectionMap = filter.getProjectionMap();
        assertTrue(filterProjectionMap != null);
        assertTrue(filterProjectionMap.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.