public static List<String> getStatsTmpDirs(BaseWork work, Configuration conf) {

    List<String> statsTmpDirs = new ArrayList<>();
    if (!StatsSetupConst.StatDB.fs.name().equalsIgnoreCase(HiveConf.getVar(conf, ConfVars.HIVE_STATS_DBCLASS))) {
      // no-op for non-fs stats collection
      return statsTmpDirs;
    }
    // if its auto-stats gather for inserts or CTAS, stats dir will be in FileSink
    Set<Operator<? extends OperatorDesc>> ops = work.getAllLeafOperators();
    if (work instanceof MapWork) {
      // if its an analyze statement, stats dir will be in TableScan
      ops.addAll(work.getAllRootOperators());
    }
    for (Operator<? extends OperatorDesc> op : ops) {
      OperatorDesc desc = op.getConf();
      String statsTmpDir = null;
      if (desc instanceof IStatsGatherDesc) {
        statsTmpDir = ((IStatsGatherDesc) desc).getTmpStatsDir();
      }
      if (statsTmpDir != null && !statsTmpDir.isEmpty()) {
        statsTmpDirs.add(statsTmpDir);
      }
    }
    return statsTmpDirs;
  }
Sets up the job so that all necessary jars ar passed that contain classes from the given argument of this method.
@param conf jobConf instance to setup
@param classes the classes to look in jars for
@throws IOException
ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java