public static Map<Path, HdfsDirSnapshot> getHdfsDirSnapshotsForCleaner(final FileSystem fs, final Path path)
          throws IOException {
    Map<Path, HdfsDirSnapshot> dirToSnapshots = new HashMap<>();
    Deque<RemoteIterator<FileStatus>> stack = new ArrayDeque<>();
    stack.push(FileUtils.listStatusIterator(fs, path, acidHiddenFileFilter));
    while (!stack.isEmpty()) {
      RemoteIterator<FileStatus> itr = stack.pop();
      while (itr.hasNext()) {
        FileStatus fStatus = itr.next();
        Path fPath = fStatus.getPath();
        if (baseFileFilter.accept(fPath) ||
                deltaFileFilter.accept(fPath) ||
                deleteEventDeltaDirFilter.accept(fPath)) {
          addToSnapshot(dirToSnapshots, fPath);
        } else {
          if (fStatus.isDirectory()) {
            stack.push(FileUtils.listStatusIterator(fs, fPath, acidHiddenFileFilter));
          } else {
            // Found an original file
            HdfsDirSnapshot hdfsDirSnapshot = addToSnapshot(dirToSnapshots, fPath.getParent());
            hdfsDirSnapshot.addFile(fStatus);
          }
        }
      }
    }
    return dirToSnapshots;
  }
In case of the cleaner, we don't need to go into file level, it is enough to collect base/delta/deletedelta directories.

@param fs the filesystem used for the directory lookup
@param path the path of the table or partition needs to be cleaned
@return The listed directory snapshot needs to be checked for cleaning
@throws IOException on filesystem errors
ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java