private static Set<Operator<?>> findAscendantOperators(SharedWorkOptimizerCache optimizerCache,
      Operator<?> start) {
    Set<Operator<?>> visited = new HashSet<>();
    visited.add(start);

    // Gather input operators
    Queue<Operator<?>> remaining = new LinkedList<>(start.getParentOperators());
    while (!remaining.isEmpty()) {
      Operator<?> op = remaining.poll();
      if (!visited.contains(op)) {
        visited.add(op);
        if (op.getParentOperators() != null) {
          remaining.addAll(op.getParentOperators());
        }
        if (op instanceof TableScanOperator) {
          // Check for DPP and semijoin DPP
          remaining.addAll(optimizerCache.tableScanToDPPSource.get((TableScanOperator) op));
        }
      }
    }

    return visited;
  }
Orders TS operators in decreasing order by "weight".
ql/src/java/org/apache/hadoop/hive/ql/optimizer/SharedWorkOptimizer.java