Package org.apache.pig.newplan.logical.relational

Examples of org.apache.pig.newplan.logical.relational.LogicalRelationalOperator


    @Override
    protected OperatorPlan buildPattern() {
        // the pattern that this rule looks for
        // is foreach -> filter
        LogicalPlan plan = new LogicalPlan();
        LogicalRelationalOperator foreach = new LOForEach(plan);
        LogicalRelationalOperator filter = new LOFilter(plan);

        plan.add(foreach);
        plan.add(filter);
        plan.connect(foreach, filter);
View Full Code Here


                Pair<List<Long>, List<Byte>> uidWithTypes = getFilterProjectionUids(filter);

                // See if the previous operators have uids from project
                List<Operator> preds = currentPlan.getPredecessors(foreach);
                for(int j=0; j< preds.size(); j++) {
                    LogicalRelationalOperator logRelOp = (LogicalRelationalOperator)preds.get(j);
                    if (hasAll(logRelOp, uidWithTypes)) {
                        forEachPred = (LogicalRelationalOperator) preds.get(j);
                        // If a filter is nondeterministic, we shouldn't push it up.
                        return !OptimizerUtils.planHasNonDeterministicUdf(filter.getFilterPlan());
                    }
View Full Code Here

                    if( op instanceof ProjectExpression ) {
                        ProjectExpression proj = (ProjectExpression)op;
                        if( proj.isProjectStar() ) {
                            //project-range is always expanded when schema is
                            //available, so nothing to do here for it
                            LogicalRelationalOperator pred = (LogicalRelationalOperator)filter.getPlan().getPredecessors(filter).get(0);
                            LogicalSchema predSchema = pred.getSchema();
                            if (predSchema!=null) {
                                for (int i=0;i<predSchema.size();i++) {
                                    uids.add(predSchema.getField(i).uid);
                                    types.add(predSchema.getField(i).type);
                                }
View Full Code Here

    @Override
    protected OperatorPlan buildPattern() {       
        // the pattern that this rule looks for
        // is filter
        LogicalPlan plan = new LogicalPlan();     
        LogicalRelationalOperator op2 = new LOFilter(plan);
        plan.add(op2);
       
        return plan;
    }
View Full Code Here

    }

    @Override
    protected OperatorPlan buildPattern() {
        LogicalPlan plan = new LogicalPlan();
        LogicalRelationalOperator foreach = new LOForEach(plan);
        plan.add( foreach );
        return plan;
    }
View Full Code Here

    }

    @Override
    protected OperatorPlan buildPattern() {
        LogicalPlan plan = new LogicalPlan();
        LogicalRelationalOperator op = new LOFilter(plan);
        plan.add(op);
        return plan;
    }
View Full Code Here

    }

    @Override
    protected OperatorPlan buildPattern() {
        LogicalPlan plan = new LogicalPlan();
        LogicalRelationalOperator limit = new LOLimit(plan, 0);
        plan.add(limit);
        return plan;
    }
View Full Code Here

    }
   
    public class TypeCastInserterTransformer extends Transformer {
        @Override
        public boolean check(OperatorPlan matched) throws FrontendException {
            LogicalRelationalOperator op = (LogicalRelationalOperator)matched.getSources().get(0);
            LogicalSchema s = op.getSchema();
            if (s == null) return false;

            // only process each node once
            if (isCastAdjusted(op)) return false;
View Full Code Here

            return false;
        }

        @Override
        public void transform(OperatorPlan matched) throws FrontendException {
            LogicalRelationalOperator op = (LogicalRelationalOperator)matched.getSources().get(0);
            LogicalSchema s = op.getSchema();
            LogicalSchema determinedSchema = determineSchema(op);

            if (currentPlan.getSuccessors(op) == null) {
                // the output of this LOAD's not going anywhere, so we don't need
                // to bother about tidying up the output
                return;
            }

            if(!atLeastOneCastNeeded(determinedSchema, s) && op instanceof LOLoad) {
                // we're not going to insert any casts, but we might reduce or increase
                // the number of columns coming out of the LOAD. If the loader supports
                // it we'll use the 'requiredColumns' functionality rather than bolting
                // on a FOREACH
                Set<Integer> required = new TreeSet<Integer>();
                for(int i = 0; i < s.size(); ++i) {
                    // if we know the data source's schema, pick out the columns we need,
                    // otherwise take the first n
                    int index = determinedSchema == null ? i : determinedSchema.findField(s.getField(i).uid);
                    if(index >= 0)
                        required.add(index);
                }

                // pass the indices of the fields we need to a pruner, and fire it off
                // so it configures the LOLoad (and the LoadFunc it contains)
                Map<LOLoad, Pair<Map<Integer, Set<String>>, Set<Integer>>> requiredMap =
                        new HashMap<LOLoad, Pair<Map<Integer,Set<String>>,Set<Integer>>>(1);
                Pair<Map<Integer, Set<String>>, Set<Integer>> pair =
                        new Pair<Map<Integer,Set<String>>, Set<Integer>>(null, required);
                requiredMap.put((LOLoad) op, pair);
                new ColumnPruneVisitor(currentPlan, requiredMap , true).visit((LOLoad) op);

                // we only want to process this node once, so mark it:
                markCastNoNeed(op);
                return;
            }

            // For every field, build a logical plan.  If the field has a type
            // other than byte array, then the plan will be cast(project).  Else
            // it will just be project.
            LogicalPlan innerPlan = new LogicalPlan();
           
            LOForEach foreach = new LOForEach(currentPlan);
            foreach.setInnerPlan(innerPlan);
            foreach.setAlias(op.getAlias());
            // Insert the foreach into the plan and patch up the plan.
            Operator next = currentPlan.getSuccessors(op).get(0);
            currentPlan.insertBetween(op, foreach, next);
           
            List<LogicalExpressionPlan> exps = new ArrayList<LogicalExpressionPlan>();
View Full Code Here

    @Override
    protected OperatorPlan buildPattern() {
        // match each foreach.
        LogicalPlan plan = new LogicalPlan();
        LogicalRelationalOperator foreach1 = new LOForEach(plan);
        plan.add( foreach1 );
        return plan;
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.newplan.logical.relational.LogicalRelationalOperator

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.