@Override
  public ParseContext transform(ParseContext pctx) throws SemanticException {
    pGraphContext = pctx;

    ReduceSinkJoinDeDuplicateProcCtx cppCtx = new ReduceSinkJoinDeDuplicateProcCtx(pGraphContext);

    Map<SemanticRule, SemanticNodeProcessor> opRules = new LinkedHashMap<SemanticRule, SemanticNodeProcessor>();
    opRules.put(new RuleRegExp("R1", ReduceSinkOperator.getOperatorName() + "%"),
        ReduceSinkJoinDeDuplicateProcFactory.getReducerMapJoinProc());

    SemanticDispatcher disp = new DefaultRuleDispatcher(
        ReduceSinkJoinDeDuplicateProcFactory.getDefaultProc(), opRules, cppCtx);
    SemanticGraphWalker ogw = new ForwardWalker(disp);

    // Create a list of topop nodes
    ArrayList<Node> topNodes = new ArrayList<Node>();
    topNodes.addAll(pGraphContext.getTopOps().values());
    ogw.startWalking(topNodes, null);
    return pGraphContext;
  }
Optimization to check whether any ReduceSink operator in the plan can be
simplified so data is not shuffled/sorted if it is already shuffled/sorted.

This optimization is executed after join algorithm selection logic has run,
and it is intended to optimize new cases that cannot be optimized when
{@link ReduceSinkDeDuplication} runs because some physical algorithms have
not been selected. Instead of removing ReduceSink operators from the plan,
they will be tagged, and then the execution plan compiler might take action,
e.g., on Tez, ReduceSink operators that just need to forward data will be
translated into a ONE-TO-ONE edge. The parallelism degree of these ReduceSink
operators might be adjusted, as a ReduceSink operator that just forwards data
cannot alter the degree of parallelism of the previous task.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/correlation/ReduceSinkJoinDeDuplication.java