Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * 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;
A visitor mechanism printing out the logical plan.
public class MRPrinter extends MROpPlanVisitor {
    private PrintStream mStream = null;
    private boolean isVerbose = true;

    

Parameters:
ps PrintStream to output plan information to
plan MR plan to print
    public MRPrinter(PrintStream psMROperPlan plan) {
        super(plannew DepthFirstWalker<MapReduceOperMROperPlan>(plan));
         = ps;
        .println("#--------------------------------------------------");
        .println("# Map Reduce Plan                                  ");
        .println("#--------------------------------------------------");
    }
    public void setVerbose(boolean verbose) {
         = verbose;
    }
    @Override
    public void visitMROp(MapReduceOper mrthrows VisitorException {
        .println("MapReduce node " + mr.getOperatorKey().toString());
        if(mr instanceof NativeMapReduceOper) {
            .println(((NativeMapReduceOper)mr).getCommandString());
            .println("--------");
            .println();
            return;
        }
        if (mr.mapPlan != null && mr.mapPlan.size() > 0) {
            .println("Map Plan");
            PlanPrinter<PhysicalOperatorPhysicalPlanprinter = new PlanPrinter<PhysicalOperatorPhysicalPlan>(mr.mapPlan);
            printer.setVerbose();
            printer.visit();
            .println("--------");
        }
        if (mr.combinePlan != null && mr.combinePlan.size() > 0) {
            .println("Combine Plan");
            PlanPrinter<PhysicalOperatorPhysicalPlanprinter = new PlanPrinter<PhysicalOperatorPhysicalPlan>(mr.combinePlan);
            printer.setVerbose();
            printer.visit();
            .println("--------");
        }
        if (mr.reducePlan != null && mr.reducePlan.size() > 0) {
            .println("Reduce Plan");
            PlanPrinter<PhysicalOperatorPhysicalPlanprinter = new PlanPrinter<PhysicalOperatorPhysicalPlan>(mr.reducePlan);
            printer.setVerbose();
            printer.visit();
            .println("--------");
        }
        .println("Global sort: " + mr.isGlobalSort());
        if (mr.getQuantFile() != null) {
            .println("Quantile file: " + mr.getQuantFile());
        }
        if (mr.getUseSecondaryKey())
            .println("Secondary sort: " + mr.getUseSecondaryKey());
        .println("----------------");
        .println("");
    }
New to GrepCode? Check out our FAQ X