public static List<HadoopShims.HdfsFileStatusWithId> listFileStatusWithId(FileSystem fs, Path dir, Ref<Boolean> useFileIds,
      boolean recursive, PathFilter filter) throws IOException {

    List<HadoopShims.HdfsFileStatusWithId> originals = new ArrayList<>();
    List<HadoopShims.HdfsFileStatusWithId> childrenWithId = tryListLocatedHdfsStatus(useFileIds, fs, dir, filter);
    if (childrenWithId != null) {
      for (HadoopShims.HdfsFileStatusWithId child : childrenWithId) {
        if (child.getFileStatus().isDirectory()) {
          if (recursive) {
            originals.addAll(listFileStatusWithId(fs, child.getFileStatus().getPath(), useFileIds,
                true, filter));
          }
        } else {
          if (child.getFileStatus().getLen() > 0) {
            originals.add(child);
          }
        }
      }
    } else {
      List<FileStatus> children = listLocatedFileStatus(fs, dir, filter, recursive);
      originals = children.stream().map(HdfsFileStatusWithoutId::new).collect(Collectors.toList());
    }
    return originals;
  }
List files recursively in the given directory.
If the filesystem supports it will use file listing with FileIds.
@param fs the filesystem
@param dir the directory to list
@param useFileIds use fileId if possible
@param recursive do recursive listing
@param filter filter to apply
@return List of files
@throws IOException ex
ql/src/java/org/apache/hadoop/hive/ql/io/HdfsUtils.java