private static void createTmpDirs(Configuration conf,
      List<Operator<? extends OperatorDesc>> ops) throws IOException {

    while (!ops.isEmpty()) {
      Operator<? extends OperatorDesc> op = ops.remove(0);

      if (op instanceof FileSinkOperator) {
        FileSinkDesc fdesc = ((FileSinkOperator) op).getConf();
        if (fdesc.isMmTable() || fdesc.isDirectInsert()) {
          // No need to create for MM tables, or ACID insert
          continue;
        }
        Path tempDir = fdesc.getDirName();
        if (tempDir != null) {
          Path tempPath = Utilities.toTempPath(tempDir);
          FileSystem fs = tempPath.getFileSystem(conf);
          fs.mkdirs(tempPath);
        }
      }

      if (op.getChildOperators() != null) {
        ops.addAll(op.getChildOperators());
      }
    }
  }
Hive uses tmp directories to capture the output of each FileSinkOperator.
This method creates all necessary tmp directories for FileSinks in the ReduceWork.

@param conf Used to get the right FileSystem
@param rWork Used to find FileSinkOperators
@throws IOException
ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java