Package org.apache.pig.impl.logicalLayer

Examples of org.apache.pig.impl.logicalLayer.FrontendException


    }

    @Override
    public void accept(PlanVisitor v) throws FrontendException {
        if (!(v instanceof LogicalExpressionVisitor)) {
            throw new FrontendException("Expected LogicalExpressionVisitor", 2222);
        }
        ((LogicalExpressionVisitor)v).visit(this);
    }
View Full Code Here


    }
   
    @Override
    public void accept(PlanVisitor v) throws FrontendException {
        if (!(v instanceof LogicalExpressionVisitor)) {
            throw new FrontendException("Expected LogicalExpressionVisitor", 2222);
        }
        ((LogicalExpressionVisitor)v).visit(this);
    }
View Full Code Here

    public PhysicalPlan compile(LogicalPlan plan,
                                Properties properties) throws FrontendException {
        if (plan == null) {
            int errCode = 2041;
            String msg = "No Plan to compile";
            throw new FrontendException(msg, errCode, PigException.BUG);
        }

        try {
            if (getConfiguration().getProperty("pig.usenewlogicalplan", "true").equals("true")) {
                log.info("pig.usenewlogicalplan is set to true. New logical plan will be used.");
               
                // translate old logical plan to new plan
                LogicalPlanMigrationVistor visitor = new LogicalPlanMigrationVistor(plan);
                visitor.visit();
                org.apache.pig.newplan.logical.relational.LogicalPlan newPlan = visitor.getNewLogicalPlan();
               
                SchemaResetter schemaResetter = new SchemaResetter(newPlan);
                schemaResetter.visit();
               
                HashSet<String> optimizerRules = null;
                try {
                    optimizerRules = (HashSet<String>) ObjectSerializer
                            .deserialize(pigContext.getProperties().getProperty(
                                    "pig.optimizer.rules"));
                } catch (IOException ioe) {
                    int errCode = 2110;
                    String msg = "Unable to deserialize optimizer rules.";
                    throw new FrontendException(msg, errCode, PigException.BUG, ioe);
                }
               
                // run optimizer
                org.apache.pig.newplan.logical.optimizer.LogicalPlanOptimizer optimizer =
                    new org.apache.pig.newplan.logical.optimizer.LogicalPlanOptimizer(newPlan, 100, optimizerRules);
                optimizer.optimize();
               
                // compute whether output data is sorted or not
                SortInfoSetter sortInfoSetter = new SortInfoSetter(newPlan);
                sortInfoSetter.visit();
               
                if (pigContext.inExplain==false) {
                    // Validate input/output file. Currently no validation framework in
                    // new logical plan, put this validator here first.
                    // We might decide to move it out to a validator framework in future
                    InputOutputFileValidator validator = new InputOutputFileValidator(newPlan, pigContext);
                    validator.validate();
                }
               
                // translate new logical plan to physical plan
                org.apache.pig.newplan.logical.relational.LogToPhyTranslationVisitor translator =
                    new org.apache.pig.newplan.logical.relational.LogToPhyTranslationVisitor(newPlan);
               
                translator.setPigContext(pigContext);
                translator.visit();
                return translator.getPhysicalPlan();
               
            }else{      
                LogToPhyTranslationVisitor translator =
                    new LogToPhyTranslationVisitor(plan);
                translator.setPigContext(pigContext);
                translator.visit();
                return translator.getPhysicalPlan();
            }
        } catch (Exception ve) {
            int errCode = 2042;
            String msg = "Error in new logical plan. Try -Dpig.usenewlogicalplan=false.";
            throw new FrontendException(msg, errCode, PigException.BUG, ve);
        }
    }
View Full Code Here

     * @link org.apache.pig.newplan.Operator#accept(org.apache.pig.newplan.PlanVisitor)
     */
    @Override
    public void accept(PlanVisitor v) throws FrontendException {
        if (!(v instanceof LogicalExpressionVisitor)) {
            throw new FrontendException("Expected LogicalExpressionVisitor", 2222);
        }
        ((LogicalExpressionVisitor)v).visit(this);
    }
View Full Code Here

           
            Operator storePred = store.getPlan().getPredecessors(store).get(0);
            if(storePred == null){
                int errCode = 2051;
                String msg = "Did not find a predecessor for Store." ;
                throw new FrontendException(msg, errCode, PigException.BUG);   
            }
           
            SortInfo sortInfo = null;
            if(storePred instanceof LOLimit) {
                storePred = store.getPlan().getPredecessors(storePred).get(0);
            } else if (storePred instanceof LOSplitOutput) {
                LOSplitOutput splitOutput = (LOSplitOutput)storePred;
                // We assume this is the LOSplitOutput we injected for this case:
                // b = order a by $0; store b into '1'; store b into '2';
                // In this case, we should mark both '1' and '2' as sorted
                LogicalExpressionPlan conditionPlan = splitOutput.getFilterPlan();
                if (conditionPlan.getSinks().size()==1) {
                    Operator root = conditionPlan.getSinks().get(0);
                    if (root instanceof ConstantExpression) {
                        Object value = ((ConstantExpression)root).getValue();
                        if (value instanceof Boolean && (Boolean)value==true) {
                            Operator split = splitOutput.getPlan().getPredecessors(splitOutput).get(0);
                            if (split instanceof LOSplit)
                                storePred = store.getPlan().getPredecessors(split).get(0);
                        }
                    }
                }
            }
            // if this predecessor is a sort, get
            // the sort info.
            if(storePred instanceof LOSort) {
                try {
                    sortInfo = ((LOSort)storePred).getSortInfo();
                } catch (FrontendException e) {
                    throw new FrontendException(e);
                }
            }
            store.setSortInfo(sortInfo);
        }
View Full Code Here

     * @link org.apache.pig.newplan.Operator#accept(org.apache.pig.newplan.PlanVisitor)
     */
    @Override
    public void accept(PlanVisitor v) throws FrontendException {
        if (!(v instanceof LogicalExpressionVisitor)) {
            throw new FrontendException("Expected LogicalExpressionVisitor", 2222);
        }
        ((LogicalExpressionVisitor)v).visit(this);
    }
View Full Code Here

     * @link org.apache.pig.newplan.Operator#accept(org.apache.pig.newplan.PlanVisitor)
     */
    @Override
    public void accept(PlanVisitor v) throws FrontendException {
        if (!(v instanceof LogicalExpressionVisitor)) {
            throw new FrontendException("Expected LogicalExpressionVisitor", 2222);
        }
        ((LogicalExpressionVisitor)v).visit(this);
    }
View Full Code Here

    private static void checkDataTypes(List<Byte> dataTypes)
            throws FrontendException {
        for (Byte type : dataTypes) {
            if (!SUPPORTED_TYPE_SET.contains(type)) {
                throw new FrontendException(
                        "Currently pig do not support this kind of type using Schema:"
                                + DataType.findTypeName(type)
                                + ". You can write shema by yourself.");
            }
        }
View Full Code Here

    private static void checkParameters(List<String> names, List<Byte> dataTypes)
            throws FrontendException {
        // TODO Auto-generated method stub
        checkDataTypes(dataTypes);
        if (names.size() != dataTypes.size()) {
            throw new FrontendException(
                    "The number of names is not equal to the number of dataTypes");
        }
    }
View Full Code Here

            if(aliasMatches.keySet().size() == 1) {
                Object[] keys = aliasMatches.keySet().toArray();
                String key = (String)keys[0];
                if(aliasMatches.get(key) > 1) {
                    int errCode = 1024;
                    throw new FrontendException("Found duplicate aliases: " + key, errCode, PigException.INPUT);
                }
                return mAliases.get(key);
            } else {
                // check if the multiple aliases obtained actually
                // point to the same field schema - then just return
                // that field schema
                Set<FieldSchema> set = new HashSet<FieldSchema>();
                for (String key: aliasMatches.keySet()) {
                    set.add(mAliases.get(key));
                }
                if(set.size() == 1) {
                    return set.iterator().next();
                }
               
                boolean hasNext = false;
                StringBuilder sb = new StringBuilder("Found more than one match: ");
                for (String key: aliasMatches.keySet()) {
                    if(hasNext) {
                        sb.append(", ");
                    } else {
                        hasNext = true;
                    }
                    sb.append(key);
                }
                int errCode = 1025;
                throw new FrontendException(sb.toString(), errCode, PigException.INPUT);
            }
        } else {
            return fs;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.logicalLayer.FrontendException

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.