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

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


                                HandleSpec streamOutputSpec = command.getOutputSpec();
                                loadFuncSpec = new FuncSpec(streamOutputSpec.getSpec());
                            } else {
                                int errCode = 2006;
                                String msg = "TypeCastInserter invoked with an invalid operator class name: " + lo.getClass().getSimpleName();
                                throw new OptimizerException(msg, errCode, PigException.BUG);
                            }
                            cast.setLoadFuncSpec(loadFuncSpec);
                            typeChanges.put(fs.canonicalName, fs.type);
                            if(determinedSchema == null) {
                                // Reset the loads field schema to byte array so that it
                                // will reflect reality.
                                fs.type = DataType.BYTEARRAY;
                            } else {
                                // Reset the type to what determinedSchema says it is
                                fs.type = determinedSchema.getField(i).type;
                            }
                        }
                }
            }

            // Build a foreach to insert after the load, giving it a cast for each
            // position that has a type other than byte array.
            LOForEach foreach = new LOForEach(mPlan,
                OperatorKey.genOpKey(scope), genPlans, flattens);
            foreach.setAlias(lo.getAlias());
            // Insert the foreach into the plan and patch up the plan.
            insertAfter(lo, foreach, null);

            rebuildSchemas();

        } catch (OptimizerException oe) {
            throw oe;
        } catch (Exception e) {
            int errCode = 2007;
            String msg = "Unable to insert type casts into plan";
            throw new OptimizerException(msg, errCode, PigException.BUG, e);
        }
    }
View Full Code Here


                                ((LogicalTransformer)rule.getTransformer()).rebuildSchemas();
                                ((LogicalTransformer)rule.getTransformer()).rebuildProjectionMaps();
                            } catch (FrontendException fee) {
                                int errCode = 2145;
                                String msg = "Problem while rebuilding projection map or schema in logical optimizer.";
                                throw new OptimizerException(msg, errCode, PigException.BUG, fee);
                            }

                        }
                        rule.getTransformer().reset();
                    }
View Full Code Here

    {
        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;
        }
        if(nodes.get(0) instanceof LOLoad) {
            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

        } catch (OptimizerException oe) {
            throw oe;
        } catch (Exception e) {
            int errCode = 2149;
            String msg = "Internal error while trying to check if filters can be pushed up.";
            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 LOFilter)) {
            // we should never be called with any other operator class name
            int errCode = 2005;
            String msg = "Expected " + LOFilter.class.getSimpleName()
                    + ", got "
                    + (lo == null ? lo : lo.getClass().getSimpleName());
            throw new OptimizerException(msg, errCode, PigException.INPUT);
        } else {
            return lo;
        }

    }
View Full Code Here

            } else if (mPushBefore) {
                if (mPushBeforeInput == -1) {
                    // something is wrong!
                    int errCode = 2150;
                    String msg = "Internal error. The push before input is not set.";
                    throw new OptimizerException(msg, errCode, PigException.BUG);
                }
                mPlan.pushBefore(predecessor, filter, mPushBeforeInput);
            }
        } catch (OptimizerException oe) {
            throw oe;
        } catch (Exception e) {
            int errCode = 2151;
            String msg = "Internal error while pushing filters up.";
            throw new OptimizerException(msg, errCode, PigException.BUG, e);
        }
    }
View Full Code Here

        TopLevelProjectFinder projectFinder = new TopLevelProjectFinder(lp);
           
        try {
            projectFinder.visit();
        } catch (VisitorException ve) {
            throw new OptimizerException();
        }
        if (projectFinder.getProjectSet()!=null && projectFinder.getProjectSet().size()==1)
        {
            LOProject project = projectFinder.getProjectSet().iterator().next();
            if (lp.getPredecessors(project)==null)
View Full Code Here

    @Override
    public boolean check(List<LogicalOperator> nodes) throws OptimizerException {
        if((nodes == null) || (nodes.size() <= 0)) {
            int errCode = 2177;
            String msg = "Cannot retrieve operator from null or empty list.";
            throw new OptimizerException(msg, errCode, PigException.BUG);
        }
       
        try {
            LogicalOperator lo = nodes.get(0);
            if (lo == null) {
                int errCode = 2178;
                String msg = "The matching node from the optimizor framework is null";
                throw new OptimizerException(msg, errCode, PigException.BUG);
            }
            if ((lo instanceof LOForEach||lo instanceof LOSplit)&&lo.getSchema()!=null)
                return true;
            return false;
        } catch (Exception e) {
            int errCode = 2179;
            String msg = "Error while performing checks to prune columns.";
            throw new OptimizerException(msg, errCode, PigException.BUG, e);
        }
    }
View Full Code Here

    public void transform(List<LogicalOperator> nodes)
            throws OptimizerException {
        if((nodes == null) || (nodes.size() <= 0)) {
            int errCode = 2177;
            String msg = "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 LOForEach || lo instanceof LOSplit)) {
                int errCode = 2178;
                String msg = "Expected " + LOForEach.class.getSimpleName() + " or " + LOSplit.class.getSimpleName();
                throw new OptimizerException(msg, errCode, PigException.BUG);
            }

            // Check if we have saved requiredInfo, if so, we will use that as required output fields for that operator;
            // Otherwise means we require every output field
            RequiredInfo requiredOutputInfo = cachedRequiredInfo.get(lo);

            if (requiredOutputInfo==null)
            {
                List<RequiredFields> requiredOutputFieldsList = new ArrayList<RequiredFields>();
                List<LogicalOperator> successors = mPlan.getSuccessors(lo);
                if (successors==null)
                {
                    requiredOutputFieldsList.add(new RequiredFields(true));
                }
                else
                {
                    // The only case requiredOutputFieldsList more than 1 element is when the current
                    // operator is LOSplit
                    for (int i=0;i<successors.size();i++)
                    {
                        requiredOutputFieldsList.add(new RequiredFields(true));
                    }
                }
                requiredOutputInfo = new RequiredInfo(requiredOutputFieldsList);
            }
            processNode(lo, requiredOutputInfo);
        } catch (OptimizerException oe) {
            throw oe;
        } catch (Exception e) {
            int errCode = 2181;
            String msg = "Unable to prune columns.";
            throw new OptimizerException(msg, errCode, PigException.BUG, e);
        }
    }
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.