Package org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.plans

Source Code of org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.plans.MRPrinter

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.plans;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.io.PrintStream;

import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceOper;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PlanPrinter;
import org.apache.pig.impl.plan.DepthFirstWalker;
import org.apache.pig.impl.plan.VisitorException;

/**
* A visitor mechanism printing out the logical plan.
*/
public class MRPrinter extends MROpPlanVisitor {

    private PrintStream mStream = null;
    private int mIndent = 0;

    /**
     * @param ps PrintStream to output plan information to
     * @param plan MR plan to print
     */
    public MRPrinter(PrintStream ps, MROperPlan plan) {
        super(plan, new DepthFirstWalker<MapReduceOper, MROperPlan>(plan));
        mStream = ps;
        mStream.println("--------------------------------------------------");
        mStream.println("| Map Reduce Plan                                |");
        mStream.println("--------------------------------------------------");
    }

    @Override
    public void visitMROp(MapReduceOper mr) throws VisitorException {
        mStream.println("MapReduce node " + mr.getOperatorKey().toString());
        if (mr.mapPlan != null && mr.mapPlan.size() > 0) {
            mStream.println("Map Plan");
            PlanPrinter printer = new PlanPrinter(mr.mapPlan, mStream);
            printer.visit();
            mStream.println("--------");
        }
        if (mr.combinePlan != null && mr.combinePlan.size() > 0) {
            mStream.println("Combine Plan");
            PlanPrinter printer = new PlanPrinter(mr.combinePlan, mStream);
            printer.visit();
            mStream.println("--------");
        }
        if (mr.reducePlan != null && mr.reducePlan.size() > 0) {
            mStream.println("Reduce Plan");
            PlanPrinter printer = new PlanPrinter(mr.reducePlan, mStream);
            printer.visit();
            mStream.println("--------");
        }
        mStream.println("Global sort: " + mr.isGlobalSort());
        if (mr.getQuantFile() != null) {
            mStream.println("Quantile file: " + mr.getQuantFile());
        }
        mStream.println("----------------");
    }
}
TOP

Related Classes of org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.plans.MRPrinter

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.