Package org.apache.pig.impl.plan

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


                }
            } else {
                sawNonKeyCol = true;
            }
        } catch (FrontendException e) {
            throw new VisitorException(e);
        }
    }
View Full Code Here


            }

            sawKey = lhsSawKey || rhsSawKey;
            sawNonKeyCol = lhsSawNonKeyCol || rhsSawNonKeyCol;
        } catch (FrontendException e) {
            throw new VisitorException(e);
        }       
    }
View Full Code Here

           
            LogicalOperator storePred = store.getPlan().getPredecessors(store).get(0);
            if(storePred == null){
                int errCode = 2051;
                String msg = "Did not find a predecessor for Store." ;
                throw new VisitorException(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
                LogicalPlan conditionPlan = splitOutput.getConditionPlan();
                if (conditionPlan.getRoots().size()==1) {
                    LogicalOperator root = conditionPlan.getRoots().get(0);
                    if (root instanceof LOConst) {
                        Object value = ((LOConst)root).getValue();
                        if (value instanceof Boolean && (Boolean)value==true) {
                            LogicalOperator 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 VisitorException(e);
                }
            }
            store.setSortInfo(sortInfo);
        }
View Full Code Here

            }
        } catch (Exception e) {
            log
                    .error("Error visiting Cogroup during Augmentation phase of Example Generator! "
                            + e.getMessage());
            throw new VisitorException(
                    "Error visiting Cogroup during Augmentation phase of Example Generator! "
                            + e.getMessage());
        }
    }
View Full Code Here

            }
        } catch (Exception e) {
            log
                    .error("Error visiting Load during Augmentation phase of Example Generator! "
                            + e.getMessage());
            throw new VisitorException(
                    "Error visiting Load during Augmentation phase of Example Generator! "
                            + e.getMessage());
        }
    }
View Full Code Here

                                    .getPredecessors(forEach)).get(0)
                                    .getSchema(), cast);
                    output.add(inputConstraint);
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new VisitorException(
                            "Operator error during Augmenting Phase in Example Generator "
                                    + e.getMessage());
                }
            }
            outputConstraintsMap.put(forEach.getPlan().getPredecessors(forEach)
View Full Code Here

        } catch (FrontendException e) {

            log
                    .error("Error visiting Load during Augmentation phase of Example Generator! "
                            + e.getMessage());
            throw new VisitorException(
                    "Error visiting Load during Augmentation phase of Example Generator! "
                            + e.getMessage());
        }
        DataBag outputConstraints = outputConstraintsMap.get(load);
        outputConstraintsMap.remove(load);
        // check if the inputData exists
        if (inputData == null || inputData.size() == 0) {
            log.error("No input data found!");
            throw new RuntimeException("No input data found!");
        }

        // first of all, we are required to guarantee that there is at least one
        // output tuple
        if (outputConstraints == null || outputConstraints.size() == 0) {
            outputConstraints = BagFactory.getInstance().newDefaultBag();
            outputConstraints.add(TupleFactory.getInstance().newTuple(
                    schema.getFields().size()));
        }

        // create example tuple to steal values from when we encounter
        // "don't care" fields (i.e. null fields)
        Tuple exampleTuple = inputData.iterator().next();

        // run through output constraints; for each one synthesize a tuple and
        // add it to the base data
        // (while synthesizing individual fields, try to match fields that exist
        // in the real data)
        for (Iterator<Tuple> it = outputConstraints.iterator(); it.hasNext();) {
            Tuple outputConstraint = it.next();

            // sanity check:
            if (outputConstraint.size() != schema.getFields().size())
                throw new RuntimeException(
                        "Internal error: incorrect number of fields in constraint tuple.");

            Tuple inputT = TupleFactory.getInstance().newTuple(
                    outputConstraint.size());
            ExampleTuple inputTuple = new ExampleTuple(inputT);

            try {
                for (int i = 0; i < inputTuple.size(); i++) {
                    Object d = outputConstraint.get(i);
                    if (d == null)
                        d = exampleTuple.get(i);
                    inputTuple.set(i, d);
                }
            } catch (ExecException e) {
                log
                        .error("Error visiting Load during Augmentation phase of Example Generator! "
                                + e.getMessage());
                throw new VisitorException(
                        "Error visiting Load during Augmentation phase of Example Generator! "
                                + e.getMessage());

            }
            if (!inputTuple.equals(exampleTuple))
View Full Code Here

            }
            currentPlan = currentPlans.pop();
            try {
                physOp.setPlans(exprPlans);
            } catch (PlanException pe) {
                throw new VisitorException(pe);
            }
            try {
                physOp.setIndex(count++);
            } catch (ExecException e1) {
                throw new VisitorException(e1);
            }
            if (plans.size() > 1) {
                type = DataType.TUPLE;
                physOp.setKeyType(type);
            } else {
                type = exprPlans.get(0).getLeaves().get(0).getResultType();
                physOp.setKeyType(type);
            }
            physOp.setResultType(DataType.TUPLE);

            currentPlan.add(physOp);

            try {
                currentPlan.connect(logToPhyMap.get(lo), physOp);
                currentPlan.connect(physOp, poc);
            } catch (PlanException e) {
                log.error("Invalid physical operators in the physical plan"
                        + e.getMessage());
                throw new VisitorException(e);
            }
           
        }
        logToPhyMap.put(cg, poc);
    }
View Full Code Here

            }
            currentPlan = currentPlans.pop();
            try {
                physOp.setPlans(exprPlans);
            } catch (PlanException pe) {
                throw new VisitorException(pe);
            }
            try {
                physOp.setIndex(count++);
            } catch (ExecException e1) {
                throw new VisitorException(e1);
            }
            if (plans.size() > 1) {
                type = DataType.TUPLE;
                physOp.setKeyType(type);
            } else {
                type = exprPlans.get(0).getLeaves().get(0).getResultType();
                physOp.setKeyType(type);
            }
            physOp.setResultType(DataType.TUPLE);

            currentPlan.add(physOp);

            try {
                currentPlan.connect(logToPhyMap.get(lo), physOp);
                currentPlan.connect(physOp, poc);
            } catch (PlanException e) {
                log.error("Invalid physical operators in the physical plan"
                        + e.getMessage());
                throw new VisitorException(e);
            }
           
        }
       
        // Append POForEach after POCogroup
        List<Boolean> flattened = new ArrayList<Boolean>();
        List<PhysicalPlan> eps = new ArrayList<PhysicalPlan>();
       
        for (int i=0;i<join.getInputs().size();i++)
        {
            PhysicalPlan ep = new PhysicalPlan();
            POProject prj = new POProject(new OperatorKey(scope,nodeGen.getNextNodeId(scope)));
            prj.setResultType(DataType.BAG);
            prj.setColumn(i+1);
            prj.setOverloaded(false);
            prj.setStar(false);
            ep.add(prj);
            eps.add(ep);
            // the parser would have marked the side
            // where we need to keep empty bags on
            // non matched as outer (innerFlags[i] would be
            // false)
            if(!(innerFlags[i])) {
                LogicalOperator joinInput = inputs.get(i);
                // for outer join add a bincond
                // which will project nulls when bag is
                // empty
                try {
                    updateWithEmptyBagCheck(ep, joinInput);
                } catch (PlanException e) {
                    throw new VisitorException(e);
                }
            }
            flattened.add(true);
        }
       
View Full Code Here

                .getPredecessors(split).get(0));
        try {
            currentPlan.connect(from, physOp);
        } catch (PlanException e) {
            log.error("Invalid physical operator in the plan" + e.getMessage());
            throw new VisitorException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.plan.VisitorException

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.