static protected void copyFiles(HiveConf conf, Path srcf, Path destf, FileSystem fs,
      boolean isSrcLocal, boolean isAcidIUD, boolean isOverwrite, List<FileStatus> newFilesStatus, boolean isBucketed,
      boolean isFullAcidTable, boolean isManaged, boolean isCompactionTable) throws HiveException {
    try {
      // create the destination if it does not exist
      if (!fs.exists(destf)) {
        FileUtils.mkdir(fs, destf, conf);
      }
    } catch (IOException e) {
      throw new HiveException(
          "copyFiles: error while checking/creating destination directory!!!",
          e);
    }

    FileStatus[] srcs;
    FileSystem srcFs;
    try {
      srcFs = srcf.getFileSystem(conf);
      srcs = srcFs.globStatus(srcf);
    } catch (IOException e) {
      LOG.error("addFiles: filesystem error in check phase", e);
      throw new HiveException("addFiles: filesystem error in check phase. " + e.getMessage(), e);
    }
    if (srcs == null) {
      LOG.info("No sources specified to move: " + srcf);
      return;
      // srcs = new FileStatus[0]; Why is this needed?
    }

    List<Path> newFiles = null;
    if (newFilesStatus != null) {
      newFiles = Collections.synchronizedList(new ArrayList<Path>());
    }

    // If we're moving files around for an ACID write then the rules and paths are all different.
    // You can blame this on Owen.
    if (isAcidIUD) {
      moveAcidFiles(srcFs, srcs, destf, newFiles, conf);
    } else {
      // For ACID non-bucketed case, the filenames have to be in the format consistent with INSERT/UPDATE/DELETE Ops,
      // i.e, like 000000_0, 000001_0_copy_1, 000002_0.gz etc.
      // The extension is only maintained for files which are compressed.
      copyFiles(conf, fs, srcs, srcFs, destf, isSrcLocal, isOverwrite,
              newFiles, isFullAcidTable && !isBucketed, isManaged, isCompactionTable);
    }

    if (newFilesStatus != null) {
      for (Path filePath : newFiles) {
        try {
          newFilesStatus.add(fs.getFileStatus(filePath));
        } catch (Exception e) {
          LOG.error("Failed to get getFileStatus", e);
          throw new HiveException(e.getMessage());
        }
      }
    }
  }
Copy files.  This handles building the mapping for buckets and such between the source and
destination
@param conf Configuration object
@param srcf source directory, if bucketed should contain bucket files
@param destf directory to move files into
@param fs Filesystem
@param isSrcLocal true if source is on local file system
@param isAcidIUD true if this is an ACID based Insert/Update/Delete
@param isOverwrite if true, then overwrite if destination file exist, else add a duplicate copy
@param newFilesStatus if this is non-null, a list of files that were created as a result of this
                move will be returned.
@param isManaged if table is managed.
@param isCompactionTable is table used in query-based compaction
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java