private void  mvFileToFinalPath(Path specPath, Configuration hconf,
      boolean success, Logger log) throws IOException, HiveException {

    FileSystem fs = specPath.getFileSystem(hconf);
    Path tmpPath = Utilities.toTempPath(specPath);
    Path intermediatePath = new Path(tmpPath.getParent(), tmpPath.getName()
        + ".intermediate");
    if (success) {
      if (fs.exists(tmpPath)) {
        // Step1: rename tmp output folder to intermediate path. After this
        // point, updates from speculative tasks still writing to tmpPath
        // will not appear in finalPath.
        Utilities.FILE_OP_LOGGER.info("Moving tmp dir: " + tmpPath + " to: " + intermediatePath + "(spec " + specPath + ")");
        Utilities.rename(fs, tmpPath, intermediatePath);
        // Step2: remove any tmp file or double-committed output files
        Utilities.removeTempOrDuplicateFiles(fs, intermediatePath, hconf, false);
        // Step3: move to the file destination
        Utilities.FILE_OP_LOGGER.info("Moving tmp dir: " + intermediatePath + " to: " + specPath);
        Utilities.renameOrMoveFiles(fs, intermediatePath, specPath);
      }
    } else {
      fs.delete(tmpPath, true);
    }
  }
This is a similar implementation of FileSinkOperator.moveFileToFinalPath.
@param specPath
@param hconf
@param success
@param log
@throws IOException
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/exec/JoinOperator.java