Github user rajat-agarwal commented on a diff in the pull request:
https://github.com/apache/spark/pull/537#discussion_r14364446
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/dstream/FileInputDStream.scala
---
@@ -97,6 +98,23 @@ class FileInputDStream[K: ClassTag, V: ClassTag, F <:
NewInputFormat[K,V] : Clas
}
/**
+ * Find files recursively in a directory
+ */
+ private def recursiveFileList(
+ fileStatuses: List[FileStatus],
+ paths: List[Path] = List[Path]()
+ ): List[Path] = fileStatuses match {
+
+ case f :: tail if (fs.getContentSummary(f.getPath).getDirectoryCount >
1) =>
+ recursiveFileList(fs.listStatus(f.getPath).toList ::: tail, paths)
+ case f :: tail if f.isDir => recursiveFileList(tail, f.getPath ::
paths)
+ case f :: tail => recursiveFileList(tail, paths)
+ case _ => paths
+
+ }
+
--- End diff --
how about this?
private def recursiveListDirs(fileStatuses: List[FileStatus],
paths: Set[Path] = Set[Path]()
): Set[Path] = fileStatuses match {
case f :: tail if f.isDir =>
recursiveListDirs(fs.listStatus(f.getPath).toList ::: tail, paths)
case f :: tail => recursiveListDirs(tail, paths + f.getPath.getParent)
case _ => paths
}
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---