@Override
  public Object dispatch(Node nd, Stack<Node> ndStack, Object... nodeOutputs)
      throws SemanticException {

    // find the firing rule
    // find the rule from the stack specified
    SemanticRule rule = null;
    int minCost = Integer.MAX_VALUE;
    for (SemanticRule r : procRules.keySet()) {
      int cost = r.cost(ndStack);
      if ((cost >= 0) && (cost <= minCost)) {
        minCost = cost;
        rule = r;
      }
    }

    SemanticNodeProcessor proc;

    if (rule == null) {
      proc = defaultProc;
    } else {
      proc = procRules.get(rule);
    }

    // Do nothing in case proc is null
    if (proc != null) {
      // Call the process function
      return proc.process(nd, ndStack, procCtx, nodeOutputs);
    } else {
      return null;
    }
  }
Dispatcher function.

@param nd
         operator to process
@param ndStack
         the operators encountered so far
@throws SemanticException
ql/src/java/org/apache/hadoop/hive/ql/lib/DefaultRuleDispatcher.java