Github user huitseeker commented on a diff in the pull request:
https://github.com/apache/spark/pull/6588#discussion_r34438876
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/dstream/FileInputDStream.scala
---
@@ -179,10 +187,55 @@ class FileInputDStream[K, V, F <: NewInputFormat[K,
V]](
)
logDebug(s"Getting new files for time $currentTime, " +
s"ignoring files older than $modTimeIgnoreThreshold")
- val filter = new PathFilter {
+ val newFileFilter = new PathFilter {
def accept(path: Path): Boolean = isNewFile(path, currentTime,
modTimeIgnoreThreshold)
}
- val newFiles = fs.listStatus(directoryPath,
filter).map(_.getPath.toString)
+ val rootDirectoryDepth = directoryDepth
+
+ // Search nested directories to find new files.
+ def searchFilesRecursively(status: FileStatus, files:
mutable.ArrayBuffer[String]): Unit = {
+ val path = status.getPath
+ if (status.isDir) {
+ // Note: A user may set depth = Int.MaxValue to search all
nested directories.
+ if (depth > path.depth() - rootDirectoryDepth) {
+ if (lastFoundDirs.contains(path)) {
+ if (status.getModificationTime > modTimeIgnoreThreshold) {
+ fs.listStatus(path).foreach(searchFilesRecursively(_,
files))
+ }
+ } else {
+ lastFoundDirs += path
+ fs.listStatus(path).foreach(searchFilesRecursively(_, files))
--- End diff --
This (and the other recursive call on l.203 above) may blow up the call
stack in very deep hierarchies (think Maildir++, etc). I realise there's a
depth limit set, but users may precisely want to set it extremely high for some
of those cases.
How about making the exploration using a @tailrec auxiliary function, with
a queue of yet-to-be-explored directories in arguments ?
---
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.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]