Examples of VisitorException


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

                currentPlan.createSoftLink(from, logToPhyMap.get(op));
            }
        } catch (PlanException e) {
            int errorCode = 2015;
            String msg = "Cannot translate soft link";
            throw new VisitorException(msg, errorCode, PigException.BUG, e);
        }
    }
View Full Code Here

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

            LogicalOperator containingNode) throws VisitorException {
        this(plan, oldNode, newNode, (Map<Integer, Integer>)null);
        if(containingNode == null) {
            int errCode = 1097;
            String msg = "Containing node cannot be null.";
            throw new VisitorException(msg, errCode, PigException.INPUT);
        }
        if(oldNodeIndex < 0) {
            int errCode = 1098;
            String msg = "Node index cannot be negative.";
            throw new VisitorException(msg, errCode, PigException.INPUT);
        }
        mContainingNode = containingNode;
        mPredecessorIndex = oldNodeIndex;
        mUseOldNode = useOldNode;
    }
View Full Code Here

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

        super(plan,
            new DepthFirstWalker<LogicalOperator, LogicalPlan>(plan));
        if(oldNode == null) {
            int errCode = 1099;
            String msg = "Node to be replaced cannot be null.";
            throw new VisitorException(msg, errCode, PigException.INPUT);
        }
        mNewNode = newNode;
        mOldNode = oldNode;
        mProjectionMapping = projectionMapping;
    }
View Full Code Here

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

        if (preds == null || preds.size() == 0) {
            if (p.getExpression().equals(mOldNode)) {
                if (mNewNode == null) {
                    int errCode = 1100;
                    String msg = "Replacement node cannot be null.";
                    throw new VisitorException(msg, errCode, PigException.INPUT);
                }

                // Change the expression
                p.setExpression(mNewNode);
                if(p.isStar()) {
                    //its a project(*)
                    //no need of changing it
                    return;
                }
                if (mContainingNode != null) {
                    // use the projection mapping of mOldNode or mNewNode along
                    // with that of mContainingNode
                    // to figure out the mapping and replace the columns
                    // appropriately
                    int oldNodeColumn = p.getCol();

                    if (mUseOldNode) {
                        // use mOldNode's projection map and find the column number
                        // from the input that
                        ProjectionMap oldNodeMap = mOldNode.getProjectionMap();

                        if (oldNodeMap == null) {
                            // bail out if the projection map is null
                            int errCode = 2156;
                            String msg = "Error while fixing projections. Projection map of node to be replaced is null.";
                            throw new VisitorException(msg, errCode,
                                    PigException.BUG);
                        }

                        if (!oldNodeMap.changes()) {
                            // no change required
                            return;
                        }

                        MultiMap<Integer, ProjectionMap.Column> oldNodeMappedFields = oldNodeMap
                                .getMappedFields();
                        if (oldNodeMappedFields == null) {
                            // there is no mapping available bail out
                            int errCode = 2157;
                            String msg = "Error while fixing projections. No mapping available in old predecessor to replace column.";
                            throw new VisitorException(msg, errCode,
                                    PigException.BUG);

                        }

                        List<ProjectionMap.Column> columns = (List<ProjectionMap.Column>) oldNodeMappedFields.get(oldNodeColumn);
                       
                        if (columns == null) {
                            // there is no mapping for oldNodeColumn
                            // it could be an added field; bail out
                            int errCode = 2158;
                            String msg = "Error during fixing projections. No mapping available in old predecessor for column to be replaced.";
                            throw new VisitorException(msg, errCode,
                                    PigException.BUG);
                        }

                        boolean foundMapping = false;
                        for (ProjectionMap.Column column : columns) {
                          Pair<Integer, Integer> pair = column.getInputColumn();
                            if (pair.first.equals(mPredecessorIndex)) {
                                ArrayList<Integer> newColumns = new ArrayList<Integer>();
                                newColumns.add(pair.second);
                                p.setProjection(newColumns);
                                foundMapping = true;
                                break;
                            }
                        }
                        if (!foundMapping) {
                            // did not find a mapping - bail out
                            int errCode = 2159;
                            String msg = "Error during fixing projections. Could not locate replacement column from the old predecessor.";
                            throw new VisitorException(msg, errCode,
                                    PigException.BUG);
                        } else {
                            // done with adjusting the column number of the
                            // project
                            return;
                        }
                    } else {
                        // here the projection mapping of new node has to be
                        // used to figure out
                        // the reverse mapping. From the newNode projection
                        // mapping search for
                        // the key whose value contains the pair (mOldNodeIndex,
                        // oldNodeColumn)

                        ProjectionMap newNodeMap = mNewNode.getProjectionMap();
                        if (newNodeMap == null) {
                            // did not find a mapping - bail out
                            int errCode = 2160;
                            String msg = "Error during fixing projections. Projection map of new predecessor is null.";
                            throw new VisitorException(msg, errCode,
                                    PigException.BUG);
                        }
                       
                        if (!newNodeMap.changes()) {
                            // no change required
                            return;
                        }

                        MultiMap<Integer, ProjectionMap.Column> newNodeMappedFields = newNodeMap
                                .getMappedFields();
                        if (newNodeMappedFields == null) {
                            // there is no mapping available bail out
                            int errCode = 2161;
                            String msg = "Error during fixing projections. No mapping available in new predecessor to replace column.";
                            throw new VisitorException(msg, errCode,
                                    PigException.BUG);

                        }

                        boolean foundMapping = false;
                        for (Integer key : newNodeMappedFields.keySet()) {

                            List<ProjectionMap.Column> columns = (List<ProjectionMap.Column>) newNodeMappedFields
                                    .get(key);
                            if (columns == null) {
                                // should not happen
                                int errCode = 2162;
                                String msg = "Error during fixing projections. Could not locate mapping for column: "
                                        + key + " in new predecessor.";
                                throw new VisitorException(msg, errCode,
                                        PigException.BUG);
                            }

                            for (ProjectionMap.Column column : columns) {
                              Pair<Integer, Integer> pair = column.getInputColumn();
                                if (pair.first.equals(mPredecessorIndex)
                                        && pair.second.equals(oldNodeColumn)) {
                                    ArrayList<Integer> newColumns = new ArrayList<Integer>();
                                    newColumns.add(key);
                                    p.setProjection(newColumns);
                                    foundMapping = true;
                                    break;
                                }
                            }

                            if (foundMapping) {
                                // done with adjusting the column number of the
                                // project
                                return;
                            }
                        }
                        if (!foundMapping) {
                            // did not find a mapping - bail out
                            int errCode = 2163;
                            String msg = "Error during fixing projections. Could not locate replacement column for column: "
                                    + oldNodeColumn
                                    + " in the new predecessor.";
                            throw new VisitorException(msg, errCode,
                                    PigException.BUG);
                        }
                    }
                }// end if for containing node != null
            }// end if for projection expression equals mOldNode
View Full Code Here

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

    @Override
    public void visit() throws VisitorException {
        try {
            mStream.write(depthFirstLP().getBytes());
        } catch (IOException e) {
            throw new VisitorException(e);
        }
    }
View Full Code Here

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

                    try{
                        currentPlan.removeAndReconnectMultiSucc(project);
                        patchInputReference(pred, project, prSuccessors);
                    }catch (PlanException pe){
                        String msg = "Error while removing redundant project in plan";
                        throw new VisitorException(msg,pe);
                    }
                }
               
            }
        }      
View Full Code Here

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

            throws VisitorException {
        try {
            binOp.getFieldSchema();
            super.visit(binOp);
        } catch (FrontendException fe) {
            throw new VisitorException(fe);
        }
    }
View Full Code Here

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

    protected void visit(UnaryExpressionOperator uniOp) throws VisitorException {
        try {
            uniOp.getFieldSchema();
            super.visit(uniOp);
        } catch (FrontendException fe) {
            throw new VisitorException(fe);
        }
    }
View Full Code Here

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

    protected void visit(LOCogroup cg) throws VisitorException {
        try {
            cg.getSchema();
            super.visit(cg);
        } catch (FrontendException fe) {
            throw new VisitorException(fe);
        }
    }
View Full Code Here

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

    protected void visit(LOJoin join) throws VisitorException {
        try {
            join.getSchema();
            super.visit(join);
        } catch (FrontendException fe) {
            throw new VisitorException(fe);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.