@Override
  public Object dispatch(Node nd, Stack<Node> stack, Object... nodeOutputs)
      throws SemanticException {
    if (nodeOutputs == null || nodeOutputs.length == 0) {
      throw new SemanticException("No Dispatch Context");
    }

    TaskGraphWalkerContext walkerCtx = (TaskGraphWalkerContext) nodeOutputs[0];

    Task<?> currTask = (Task<?>) nd;
    // not map reduce task or not conditional task, just skip
    if (currTask.isMapRedTask()) {
      if (currTask instanceof ConditionalTask) {
        // get the list of task
        List<Task<?>> taskList = ((ConditionalTask) currTask).getListTasks();
        for (Task<?> tsk : taskList) {
          if (tsk.isMapRedTask()) {
            Task<?> newTask = this.processCurrentTask((MapRedTask) tsk,
                ((ConditionalTask) currTask), physicalContext.getContext());
            walkerCtx.addToDispatchList(newTask);
          }
        }
      } else {
        Task<?> newTask =
            this.processCurrentTask((MapRedTask) currTask, null, physicalContext.getContext());
        walkerCtx.addToDispatchList(newTask);
      }
    }
    return null;
  }
Common iteration methods for converting joins and sort-merge joins.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/AbstractJoinTaskDispatcher.java