Package org.apache.pig.impl.plan

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


       
        List<RequiredFields> result = new ArrayList<RequiredFields>();
        for(int inputNum = 0; inputNum < predecessors.size(); ++inputNum) {
           
            if(inputNum == column-1) {
                result.add(new RequiredFields(true));
            } else {
                result.add(null);
            }
        }
        return result;
View Full Code Here


                starRequired = true;
            }
        }

        if(starRequired) {
            requiredFields.add(new RequiredFields(true));
            return requiredFields;
        } else {
            for (LOProject project : projectSet) {
                for (int inputColumn : project.getProjection()) {
                    fields.add(new Pair<Integer, Integer>(0, inputColumn));
                }
            }
   
            if(fields.size() == 0) {
                requiredFields.add(new RequiredFields(false, true));
            } else {               
                requiredFields.add(new RequiredFields(new ArrayList<Pair<Integer, Integer>>(fields)));
            }
            return (requiredFields.size() == 0? null: requiredFields);
        }
    }
View Full Code Here

            projectFinder.visit();
        } catch (VisitorException ve) {
            return null;
        }
        if(projectFinder.getProjectStarSet() != null) {
            result.add(new RequiredFields(true));
            return result;
        }

        ArrayList<Pair<Integer, Integer>> inputList = new ArrayList<Pair<Integer, Integer>>();
        for (LOProject project : projectFinder.getProjectSet()) {
            for (int inputColumn : project.getProjection()) {
                if (!inputList.contains(new Pair<Integer, Integer>(0, inputColumn)))
                    inputList.add(new Pair<Integer, Integer>(0, inputColumn));
            }
        }
        if (inputList.size()==0)
            return null;

        result.add(new RequiredFields(inputList));
       
        return result;
    }
View Full Code Here

                    groupByStar = true;
                }
            }

            if(groupByStar) {
                requiredFields.add(new RequiredFields(true));
            } else {               
                for (LOProject project : projectSet) {
                    for (int inputColumn : project.getProjection()) {
                        fields.add(new Pair<Integer, Integer>(inputNum, inputColumn));
                    }
                }
       
                if(fields.size() == 0) {
                    requiredFields.add(new RequiredFields(false, true));
                } else {               
                    requiredFields.add(new RequiredFields(new ArrayList<Pair<Integer, Integer>>(fields)));
                }
            }
        }
       
        return (requiredFields.size() == 0? null: requiredFields);
View Full Code Here

                inputColumn++;
        }

        ArrayList<Pair<Integer, Integer>> inputList = new ArrayList<Pair<Integer, Integer>>();
        inputList.add(new Pair<Integer, Integer>(inputNum, inputColumn));
        RequiredFields requiredFields = new RequiredFields(inputList);
        result.set(inputNum, requiredFields);
        return result;
    }
View Full Code Here

    }
   
    @Override
    public List<RequiredFields> getRequiredFields() {
        List<RequiredFields> requiredFields = new ArrayList<RequiredFields>();
        requiredFields.add(new RequiredFields(false, true));
        return requiredFields;
    }
View Full Code Here

        }
       
        ArrayList<Pair<Integer, Integer>> inputList = new ArrayList<Pair<Integer, Integer>>();
        inputList.add(new Pair<Integer, Integer>(0, column));
        List<RequiredFields> result = new ArrayList<RequiredFields>();
        result.add(new RequiredFields(inputList));
        return result;
    }
View Full Code Here

    }

    @Override
    public List<RequiredFields> getRequiredFields() {
        List<RequiredFields> requiredFields = new ArrayList<RequiredFields>();
        requiredFields.add(new RequiredFields(false, true));
        return requiredFields;
    }
View Full Code Here

            if (column >= mSchema.size())
                return null;
        }
       
        List<RequiredFields> result = new ArrayList<RequiredFields>();
        result.add(new RequiredFields(true));
        return result;
    }
View Full Code Here

            IndexHelper<LogicalOperator> indexHelper = new IndexHelper<LogicalOperator>(peers);
            Integer foreachPosition = indexHelper.getIndex(foreach);
           
            // Check if flattened fields is required by successor, if so, don't optimize
            List<RequiredFields> requiredFieldsList = ((RelationalOperator)successor).getRequiredFields();
            RequiredFields requiredFields = requiredFieldsList.get(foreachPosition.intValue());
           
            MultiMap<Integer, Column> foreachMappedFields = foreachProjectionMap.getMappedFields();
           
            if (requiredFields.getFields()!=null) {
                for (Pair<Integer, Integer> pair : requiredFields.getFields()) {
                    Collection<Column> columns = foreachMappedFields.get(pair.second);
                    if (columns!=null) {
                        for (Column column : columns) {
                            Pair<Integer, Integer> foreachInputColumn = column.getInputColumn();
                            if (foreach.isInputFlattened(foreachInputColumn.second))
                                return false;
                        }
                    }
                }
            }
           
            // the foreach with flatten can be swapped with an order by
            // as the order by will have lesser number of records to sort
            // also the sort does not alter the records that are processed
           
            // the foreach with flatten can be pushed down a cross or a join
            // for the same reason. In this case the foreach has to be first
            // unflattened and then a new foreach has to be inserted after
            // the cross or join. In both cross and foreach the actual columns
            // from the foreach are not altered but positions might be changed
           
            // in the case of union the column is transformed and as a result
            // the foreach flatten cannot be pushed down
           
            // for distinct the output before flattening and the output
            // after flattening might be different. For example, consider
            // {(1), (1)}. Distinct of this bag is still {(1), (1)}.
            // distinct(flatten({(1), (1)})) is (1). However,
            // flatten(distinct({(1), (1)})) is (1), (1)
           
            // in both cases correctness is not affected
            if(successor instanceof LOSort) {
                LOSort sort = (LOSort) successor;
                RequiredFields sortRequiredField = sort.getRequiredFields().get(0);
               
                if(sortRequiredField.getNeedAllFields()) {
                    return false;
                }
               
                List<Pair<Integer, Integer>> sortInputs = sortRequiredField.getFields();
                Set<Integer> requiredInputs = new HashSet<Integer>();
                for(Pair<Integer, Integer> pair: sortInputs) {
                    requiredInputs.add(pair.second);
                }
               
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.