Package org.apache.pig.impl.plan

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


            return mProjectionMap;
        }

        if(Schema.equals(inputSchema, outputSchema, false, true)) {
            //there is a one is to one mapping between input and output schemas
            mProjectionMap = new ProjectionMap(false);
            return mProjectionMap;
        } else {
            //problem - input and output schemas for a sort have to match!
            mProjectionMap = null;
            return mProjectionMap;
View Full Code Here


       
        if(addedFields.size() == 0) {
            addedFields = null;
        }

        mProjectionMap = new ProjectionMap(mapFields, null, addedFields);
        return mProjectionMap;
    }
View Full Code Here

                    mapFields.put(inputColumn, new ProjectionMap.Column(new Pair<Integer, Integer>(inputNum, inputColumn)));
                }
            }
        }
       
        mProjectionMap = new ProjectionMap(mapFields, null, null);
        return mProjectionMap;
    }
View Full Code Here

            return mProjectionMap;
        }
       
        if(Schema.equals(inputSchema, outputSchema, false, true)) {
            //there is a one is to one mapping between input and output schemas
            mProjectionMap = new ProjectionMap(false);
            return mProjectionMap;
        } else {
            //problem - input and output schemas for a filter have to match!
            mProjectionMap = null;
            return mProjectionMap;
View Full Code Here

            return mProjectionMap;
        }

        if(Schema.equals(inputSchema, outputSchema, false, true)) {
            //there is a one is to one mapping between input and output schemas
            mProjectionMap = new ProjectionMap(false);
            return mProjectionMap;
        } else {
            //problem - input and output schemas for a distinct have to match!
            mProjectionMap = null;
            return mProjectionMap;
View Full Code Here

            return mProjectionMap;
        }
       
        if(Schema.equals(inputSchema, outputSchema, false, true)) {
            //there is a one is to one mapping between input and output schemas
            mProjectionMap = new ProjectionMap(false);
            return mProjectionMap;
        } else {
            //problem - input and output schemas for a distinct have to match!
            mProjectionMap = null;
            return mProjectionMap;
View Full Code Here

        String query = "foreach (load 'a') generate $1,$2;";
        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);

        MultiMap<Integer, ProjectionMap.Column> foreachMapFields = foreachProjectionMap.getMappedFields();
        assertTrue(foreachMapFields != null);
       
        List<ProjectionMap.Column> 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);
       
        assertTrue(foreachProjectionMap.getRemovedFields() == null);
        assertTrue(foreachProjectionMap.getAddedFields() == null);
       
    }
View Full Code Here

        String query = "foreach (load 'a' using " + PigStorage.class.getName() + "(':')) generate $1, 'aoeuaoeu' ;";
        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);
       
        MultiMap<Integer, ProjectionMap.Column> foreachMapFields = foreachProjectionMap.getMappedFields();
        assertTrue(foreachMapFields != null);
       
        List<ProjectionMap.Column> mapValues = (ArrayList<ProjectionMap.Column>)foreachMapFields.get(0);
        assertTrue(mapValues.get(0).getInputColumn().first == 0);
        assertTrue(mapValues.get(0).getInputColumn().second == 1);

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

        String query = "foreach (cogroup (load 'a') by $1, (load 'b') by $1) generate org.apache.pig.builtin.AVG($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);
        assertTrue(foreachProjectionMap.getMappedFields() == null);

        //check that removed fields has all the columns from the input cogroup
        List<Pair<Integer, Integer>> foreachRemovedFields = foreachProjectionMap.getRemovedFields();
        assertTrue(foreachProjectionMap.getRemovedFields().size() == 3);
        int expectedColumn = 0;
        for(Pair<Integer, Integer> removedField: foreachRemovedFields) {
            assertTrue(removedField.first == 0);
            assertTrue(removedField.second == expectedColumn++);
        }
       
        //check that added fields contain [0]
        List<Integer> foreachAddedFields = foreachProjectionMap.getAddedFields();
        assertTrue(foreachAddedFields.size() == 1);
        assertTrue(foreachAddedFields.get(0) == 0);
    }
View Full Code Here

        String query = "foreach (group (load 'a') ALL) generate $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);
       
        //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);
       
        //check the cogroup removed fields is null
        assertTrue(cogroupProjectionMap.getRemovedFields() == null);
       
        //check that cogroup added fields contain [0, 1]
        List<Integer> cogroupAddedFields = cogroupProjectionMap.getAddedFields();
        assertTrue(cogroupAddedFields.size() == 2);
        assertTrue(cogroupAddedFields.get(0) == 0);
        assertTrue(cogroupAddedFields.get(1) == 1);
       
        //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> foreachMappedFields = foreachProjectionMap.getMappedFields();
        assertTrue(foreachMappedFields != null);
       
        List<ProjectionMap.Column> mapValues = (ArrayList<ProjectionMap.Column>)foreachMappedFields.get(0);
        assertTrue(mapValues.get(0).getInputColumn().first == 0);
        assertTrue(mapValues.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(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

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.