Package org.apache.pig.backend.hadoop.executionengine.physicalLayer

Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator


            if (mpLeaves.size() != 1) {
                int errCode = 2024;
                String msg = "Expected reduce to have single leaf. Found " + mpLeaves.size() + " leaves.";
                throw new MRCompilerException(msg, errCode, PigException.BUG);
            }
            PhysicalOperator mpLeaf = mpLeaves.get(0);
            if (!(mpLeaf instanceof POStore)) {
                int errCode = 2025;
                String msg = "Expected leaf of reduce plan to " +
                    "always be POStore. Found " + mpLeaf.getClass().getSimpleName();
                throw new MRCompilerException(msg, errCode, PigException.BUG);
            }
            List<PhysicalOperator> preds =
                mr.reducePlan.getPredecessors(mpLeaf);
            if (preds == null) return;
            if (preds.size() > 1) {
                int errCode = 2030;
                String msg ="Expected reduce plan leaf to have a single predecessor. Found " + preds.size() + " predecessors.";
                throw new MRCompilerException(msg, errCode, PigException.BUG);
            }
            PhysicalOperator pred = preds.get(0);
            if (!(pred instanceof POLocalRearrange)) return;

            // Next question, does the next MROper have an empty map?
            List<MapReduceOper> succs = mPlan.getSuccessors(mr);
            if (succs == null) {
                int errCode = 2031;
                String msg = "Found map reduce operator with POLocalRearrange as"
                    + " last oper but with no succesor.";
                throw new MRCompilerException(msg, errCode, PigException.BUG);
            }
            if (succs.size() > 1) {
                int errCode = 2032;
                String msg = "Expected map reduce operator to have a single successor. Found " + succs.size() + " successors.";
                throw new MRCompilerException(msg, errCode, PigException.BUG);
            }
            MapReduceOper succ = succs.get(0);
            List<PhysicalOperator> succMpLeaves = succ.mapPlan.getLeaves();
            List<PhysicalOperator> succMpRoots = succ.mapPlan.getRoots();
            if (succMpLeaves == null || succMpLeaves.size() > 1 ||
                    succMpRoots == null || succMpRoots.size() > 1 ||
                    succMpLeaves.get(0) != succMpRoots.get(0)) {
                messageCollector.collect("Expected to find subsequent map " +
                    "with just a load, but didn't",
                    MessageType.Warning, PigWarning.DID_NOT_FIND_LOAD_ONLY_MAP_PLAN);
                return;
            }
            PhysicalOperator load = succMpRoots.get(0);

            try {
                mr.reducePlan.removeAndReconnect(pred);
                succ.mapPlan.add(pred);
                succ.mapPlan.connect(load, pred);
View Full Code Here


                if (mpLeaves.size() != 1) {
                    int errCode = 2024;
                    String msg = "Expected reduce to have single leaf. Found " + mpLeaves.size() + " leaves.";
                    throw new MRCompilerException(msg, errCode, PigException.BUG);
                }
                PhysicalOperator mpLeaf = mpLeaves.get(0);
                if (!(mpLeaf instanceof POStore)) {
                    int errCode = 2025;
                    String msg = "Expected leaf of reduce plan to " +
                        "always be POStore. Found " + mpLeaf.getClass().getSimpleName();
                    throw new MRCompilerException(msg, errCode, PigException.BUG);
                }
                FileSpec oldSpec = ((POStore)mpLeaf).getSFile();
                boolean oldIsTmpStore = ((POStore)mpLeaf).isTmpStore();
               
View Full Code Here

        // from sortMROp to the new MROp so that the sort keys aren't lost by
        // projection in sortMROp.
        private void fixProjectionAfterLimit(MapReduceOper mro,
                MapReduceOper sortMROp) throws PlanException, VisitorException {
                       
            PhysicalOperator op = sortMROp.reducePlan.getRoots().get(0);
            assert(op instanceof POPackage);
           
            op = sortMROp.reducePlan.getSuccessors(op).get(0);
            assert(op instanceof POForEach);
           
            while (true) {
                List<PhysicalOperator> succs = sortMROp.reducePlan
                        .getSuccessors(op);
                if (succs==null) break;
                op = succs.get(0);
                if (op instanceof POForEach) break;
            }
           
            while (true) {
                if (op instanceof POStore) break;
                PhysicalOperator opToMove = op;
                List<PhysicalOperator> succs = sortMROp.reducePlan
                        .getSuccessors(op);
                op = succs.get(0);
               
                sortMROp.reducePlan.removeAndReconnect(opToMove);
View Full Code Here

                // The first item inside columnChainInfo is set to type Tuple.
                // This value is not actually in use, but it intends to match
                // the type of POProject in reduce side
                columnChainInfo.insert(false, columns, DataType.TUPLE);

                PhysicalOperator node = plan.getRoots().get(0);
                while (node != null) {
                    if (node instanceof POProject) {
                        POProject project = (POProject) node;

                        columnChainInfo.insert(project.isStar(), project
View Full Code Here

        if (mapLeaves == null || mapLeaves.size() != 1) {
            log
                    .debug("Expected map to have single leaf! Skip secondary key optimizing");
            return;
        }
        PhysicalOperator mapLeaf = mapLeaves.get(0);

        // Figure out the main key of the map-reduce job from POLocalRearrange
        try {
            if (mapLeaf instanceof POLocalRearrange) {
                SortKeyInfo sortKeyInfo = getSortKeyInfo((POLocalRearrange) mapLeaf);
                if (sortKeyInfo == null) {
                    log
                            .debug("Cannot get sortKeyInfo from POLocalRearrange, skip secondary key optimizing");
                    return;
                }
                sortKeyInfos.add(sortKeyInfo);
            } else if (mapLeaf instanceof POUnion) {
                List<PhysicalOperator> preds = mr.mapPlan
                        .getPredecessors(mapLeaf);
                for (PhysicalOperator pred : preds) {
                    if (pred instanceof POLocalRearrange) {
                        SortKeyInfo sortKeyInfo = getSortKeyInfo((POLocalRearrange) pred);
                        if (sortKeyInfo == null) {
                            log.debug("Cannot get sortKeyInfo from POLocalRearrange, skip secondary key optimizing");
                            return;
                        }
                        sortKeyInfos.add(sortKeyInfo);
                    }
                }
            } else {
                log.debug("Cannot find POLocalRearrange or POUnion in map leaf, skip secondary key optimizing");
                return;
            }
        } catch (ExecException e) {
            log
                    .debug("Cannot get sortKeyInfo from POLocalRearrange, skip secondary key optimizing");
            return;
        }

        if (mr.reducePlan.isEmpty()) {
            log.debug("Reduce plan is empty, skip secondary key optimizing");
            return;
        }

        List<PhysicalOperator> reduceRoots = mr.reducePlan.getRoots();
        if (reduceRoots.size() != 1) {
            log
                    .debug("Expected reduce to have single root, skip secondary key optimizing");
            return;
        }

        PhysicalOperator root = reduceRoots.get(0);
        if (!(root instanceof POPackage)) {
            log
                    .debug("Expected reduce root to be a POPackage, skip secondary key optimizing");
            return;
        }

        // visit the POForEach of the reduce plan. We can have Limit and Filter
        // in the middle
        PhysicalOperator currentNode = root;
        POForEach foreach = null;
        while (currentNode != null) {
            if (currentNode instanceof POPackage && !(currentNode instanceof POJoinPackage)
                    || currentNode instanceof POFilter
                    || currentNode instanceof POLimit) {
View Full Code Here

            int errorCode = 2207;
            throw new PlanException(
                    "POForEach inner plan has more than 1 root", errorCode);
        }

        PhysicalOperator currentNode = plan.getRoots().get(0);

        while (currentNode != null) {
            if (currentNode instanceof POProject) {
                POProject project = (POProject) currentNode;
                columnChainInfo.insertInReduce(project.isStar(), project
View Full Code Here

               
                rp.attachInput(packRes);

                List<PhysicalOperator> leaves = rp.getLeaves();
               
                PhysicalOperator leaf = leaves.get(0);
                runPipeline(leaf);
               
            }
           
            if(res.returnStatus==POStatus.STATUS_NULL) {
View Full Code Here

                processRoot(root);
            }
        }
       
        public void processRoot(PhysicalOperator root) throws FrontendException {
            PhysicalOperator currentNode = root;
            while (currentNode!=null) {
                boolean sawInvalidPhysicalOper = false;
                if (currentNode instanceof PODistinct)
                    sawInvalidPhysicalOper = processDistinct((PODistinct)currentNode);
                else if (currentNode instanceof POSort)
View Full Code Here

            MapReduceOper mo2 = mp.getLeaves().get(0);
            MapReduceOper mo3 = mp.getLeaves().get(1);

            checkPhysicalPlan(mo1.mapPlan, 1, 1, 3);
            checkPhysicalPlan(mo1.reducePlan, 1, 1, 2);
            PhysicalOperator leaf = mo1.reducePlan.getLeaves().get(0);
           
            Assert.assertTrue(leaf instanceof POSplit);

            POSplit split = (POSplit)leaf;
           
View Full Code Here

            MapReduceOper mo1 = mp.getRoots().get(0);
            MapReduceOper mo2 = mp.getLeaves().get(0);

            checkPhysicalPlan(mo1.mapPlan, 1, 1, 3);
            checkPhysicalPlan(mo1.reducePlan, 1, 1, 2);
            PhysicalOperator leaf = mo1.reducePlan.getLeaves().get(0);
           
            Assert.assertTrue(leaf instanceof POStore);
           
            checkPhysicalPlan(mo2.mapPlan, 1, 1, 2);
            checkPhysicalPlan(mo2.reducePlan, 1, 1, 2);
View Full Code Here

TOP

Related Classes of org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator

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.