Package org.apache.pig.impl.plan.optimizer

Examples of org.apache.pig.impl.plan.optimizer.OptimizerException


    {
        if((nodes == null) || (nodes.size() <= 0)) {
            int errCode = 2052;
            String msg = "Internal error. Cannot retrieve operator from null " +
                "or empty list.";
            throw new OptimizerException(msg, errCode, PigException.BUG);
        }
        if(nodes.size() != 1|| !(nodes.get(0) instanceof LOLoad)) {
            return false;
        }
        if (!alreadyChecked.add(nodes.get(0))) {
            return false;
        }
        loLoad = (LOLoad)nodes.get(0);
        List<LogicalOperator> sucs = mPlan.getSuccessors(loLoad);
        if(sucs == null || sucs.size() != 1 || !(sucs.get(0) instanceof LOFilter)) {
            return false;
        }
        loFilter = (LOFilter)sucs.get(0);
       
        // we have to check more only if LoadFunc implements LoadMetada
        loadFunc = loLoad.getLoadFunc();
        if(!(loadFunc instanceof LoadMetadata)) {
            return false;
        }
        loadMetadata = (LoadMetadata)loadFunc;
        try {
            partitionKeys = loadMetadata.getPartitionKeys(
                    loLoad.getInputFile().getFileName(), new Job(loLoad.getConfiguration()));
            if(partitionKeys == null || partitionKeys.length == 0) {
                return false;
            }
        } catch (IOException e) {
            int errCode = 2209;
            throw new OptimizerException(
                    "Internal error while processing any partition filter " +
                    "conditions in the filter after the load" ,
                    errCode,
                    PigException.BUG
            );
View Full Code Here


                    mPlan.removeAndReconnect(loFilter);
                }
            }
        } catch (Exception e) {
            int errCode = 2209;
            throw new OptimizerException(
                    "Internal error while processing any partition filter " +
                    "conditions in the filter after the load:" ,
                    errCode,
                    PigException.BUG,
                    e
View Full Code Here

                                // We shall allow inconsistent pruning for union, and the pruneColumns method
                                // in LOUnion will handle this inconsistency
                                if (!(lOp instanceof LOUnion) && columnPruned==true) {
                                    int errCode = 2185;
                                    String msg = "Column $"+i+" of "+lOp+" inconsistent pruning";
                                    throw new OptimizerException(msg, errCode, PigException.BUG);
                                }
                            }
                        }
                    }
                }
View Full Code Here

                if(distinct != null) {
                    // we should not already have been patched since the
                    // Project-Distinct pair should occur only once
                    int errCode = 2076;
                    String msg = "Unexpected Project-Distinct pair while trying to set up plans for use with combiner.";
                    throw new OptimizerException(msg, errCode, PigException.BUG);
                }
                // we have stick in the POUserfunc(org.apache.pig.builtin.Distinct)[DataBag]
                // in place of the Project-PODistinct pair
                PhysicalOperator distinctPredecessor = mPlan.getPredecessors(pred).get(0);

                POUserFunc func = null;

                try {
                    String scope = proj.getOperatorKey().scope;
                    List<PhysicalOperator> funcInput = new ArrayList<PhysicalOperator>();
                    FuncSpec fSpec = new FuncSpec(DISTINCT_UDF_CLASSNAME);
                    funcInput.add(distinctPredecessor);
                    // explicitly set distinctPredecessor's result type to
                    // be tuple - this is relevant when distinctPredecessor is
                    // originally a POForeach with return type BAG - we need to
                    // set it to tuple so we get a stream of tuples.
                    distinctPredecessor.setResultType(DataType.TUPLE);
                    func = new POUserFunc(new OperatorKey(scope,
                            NodeIdGenerator.getGenerator().getNextNodeId(scope)),-1, funcInput, fSpec);
                    func.setResultType(DataType.BAG);
                    mPlan.replace(proj, func);
                    mPlan.remove(pred);
                    // connect the the newly added "func" to
                    // the predecessor to the earlier PODistinct
                    mPlan.connect(distinctPredecessor, func);
                } catch (PlanException e) {
                    int errCode = 2077;
                    String msg = "Problem with reconfiguring plan to add distinct built-in function.";
                    throw new OptimizerException(msg, errCode, PigException.BUG, e);
                }
                distinct = func;
            }
        }
View Full Code Here

                // there should be only one successor to package
                sucs.get(0).setInputs(packList);
            } catch (Exception e) {
                int errCode = 2018;
                String msg = "Internal error. Unable to introduce the combiner for optimization.";
                throw new OptimizerException(msg, errCode, PigException.BUG, e);
            }
        }
    }
View Full Code Here

        } catch (OptimizerException oe) {
            throw oe;
        } catch (Exception e) {
            int errCode = 2152;
            String msg = "Internal error while trying to check if foreach with flatten can be pushed down.";
            throw new OptimizerException(msg, errCode, PigException.BUG, e);
        }
    }
View Full Code Here

    private LogicalOperator getOperator(List<LogicalOperator> nodes)
            throws FrontendException {
        if ((nodes == null) || (nodes.size() <= 0)) {
            int errCode = 2052;
            String msg = "Internal error. Cannot retrieve operator from null or empty list.";
            throw new OptimizerException(msg, errCode, PigException.BUG);
        }

        LogicalOperator lo = nodes.get(0);
        if (lo == null || !(lo instanceof LOForEach)) {
            // we should never be called with any other operator class name
            int errCode = 2005;
            String msg = "Expected " + LOForEach.class.getSimpleName()
                    + ", got "
                    + (lo == null ? lo : lo.getClass().getSimpleName());
            throw new OptimizerException(msg, errCode, PigException.INPUT);
        } else {
            return lo;
        }

    }
View Full Code Here

                // in the new foreach operator
               
                if(mFlattenedColumnReMap == null) {
                    int errCode = 2153;
                    String msg = "Internal error. The mapping for the flattened columns is empty";
                    throw new OptimizerException(msg, errCode, PigException.BUG);
                }
               
                // set flatten to false for all columns in the mapping
               
                ArrayList<Boolean> flattenList = (ArrayList<Boolean>)foreach.getFlatten();               
                for(Integer key: mFlattenedColumnReMap.keySet()) {
                    flattenList.set(key, false);
                }
               
                // rebuild schemas of the foreach and the successor after the foreach modification
                foreach.regenerateSchema();
                successor.regenerateSchema();
               
                Schema successorSchema = successor.getSchema();
               
                if(successorSchema == null) {
                    int errCode = 2154;
                    String msg = "Internal error. Schema of successor cannot be null for pushing down foreach with flatten.";
                    throw new OptimizerException(msg, errCode, PigException.BUG);
                }
               
                flattenList = new ArrayList<Boolean>();
               
                ArrayList<LogicalPlan> foreachInnerPlans = new ArrayList<LogicalPlan>();
               
                for(int i = 0; i < successorSchema.size(); ++i) {
                    LogicalPlan innerPlan = new LogicalPlan();
                    LOProject project = new LOProject(innerPlan, OperatorKey
                            .genOpKey(foreach.getOperatorKey().scope),
                            successor, i);
                    innerPlan.add(project);
                    foreachInnerPlans.add(innerPlan);
                    flattenList.add(false);
                }
               
                // set the flattened remapped column to true
                for(Integer key: mFlattenedColumnReMap.keySet()) {
                    Integer value = mFlattenedColumnReMap.get(key);
                    flattenList.set(value, true);
                }           
               
               
                LOForEach newForeach = new LOForEach(mPlan, OperatorKey
                        .genOpKey(foreach.getOperatorKey().scope), foreachInnerPlans,
                        flattenList);
               
                // add the new foreach to the plan
                mPlan.add(newForeach);
               
                // insert the new foreach between the successor and the successor's successor
                mPlan.insertBetween(successor, newForeach, mPlan.getSuccessors(successor).get(0));            
            }
        } catch (OptimizerException oe) {
            throw oe;
        } catch (Exception e) {
            int errCode = 2155;
            String msg = "Internal error while pushing foreach with flatten down.";
            throw new OptimizerException(msg, errCode, PigException.BUG, e);
        }
    }
View Full Code Here

    @Override
    public boolean check(List<LogicalOperator> nodes) throws OptimizerException {
        if((nodes == null) || (nodes.size() <= 0)) {
            int errCode = 2052;
            String msg = "Internal error. Cannot retrieve operator from null or empty list.";
            throw new OptimizerException(msg, errCode, PigException.BUG);
        }
       
        try {
            LogicalOperator lo = nodes.get(0);
            if (lo == null || !(lo instanceof LOLimit)) {
                int errCode = 2005;
                String msg = "Expected " + LOLimit.class.getSimpleName()
                        + ", got "
                        + (lo == null ? lo : lo.getClass().getSimpleName());
                throw new OptimizerException(msg, errCode, PigException.BUG);
            }
        } catch (Exception e) {
            int errCode = 2049;
            String msg = "Error while performing checks to optimize limit operator.";
            throw new OptimizerException(msg, errCode, PigException.BUG);
        }

        return true;
    }
View Full Code Here

    @Override
    public void transform(List<LogicalOperator> nodes) throws OptimizerException {       
        if((nodes == null) || (nodes.size() <= 0)) {
            int errCode = 2052;
            String msg = "Internal error. Cannot retrieve operator from null or empty list.";
            throw new OptimizerException(msg, errCode, PigException.BUG);
        }
        try {
            LogicalOperator lo = nodes.get(0);
            if (lo == null || !(lo instanceof LOLimit)) {
                int errCode = 2005;
                String msg = "Expected " + LOLimit.class.getSimpleName() + ", got " + lo.getClass().getSimpleName();
                throw new OptimizerException(msg, errCode, PigException.BUG);
            }

            LOLimit limit = (LOLimit)lo;
           
            processNode(limit);
        } catch (OptimizerException oe) {
            throw oe;
        } catch (Exception e) {
            int errCode = 2050;
            String msg = "Internal error. Unable to optimize limit operator.";
            throw new OptimizerException(msg, errCode, PigException.BUG);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.plan.optimizer.OptimizerException

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.