public long getTotalKnownInputSize(Context context, MapWork currWork,
      Map<Path, List<String>> pathToAliases,
      Map<String, Long> aliasToSize) throws SemanticException {
    try {
      // go over all the input paths, and calculate a known total size, known
      // size for each input alias.
      Utilities.getInputSummary(context, currWork, null).getLength();

      // set alias to size mapping, this can be used to determine if one table
      // is chosen as big table, what's the total size of left tables, which
      // are going to be small tables.
      long aliasTotalKnownInputSize = 0L;
      for (Map.Entry<Path, List<String>> entry : pathToAliases.entrySet()) {
        Path path = entry.getKey();
        List<String> aliasList = entry.getValue();
        ContentSummary cs = context.getCS(path);
        if (cs != null) {
          long size = cs.getLength();
          for (String alias : aliasList) {
            aliasTotalKnownInputSize += size;
            Long es = aliasToSize.get(alias);
            if (es == null) {
              es = Long.valueOf(0);
            }
            es += size;
            aliasToSize.put(alias, es);
          }
        }
      }
      return aliasTotalKnownInputSize;
    } catch (Exception e) {
      throw new SemanticException("Generate Map Join Task Error: ", e);
    }
  }
Common iteration methods for converting joins and sort-merge joins.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/AbstractJoinTaskDispatcher.java