File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
core/src/main/scala/org/apache/spark/deploy Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,27 @@ private[spark] class SparkHadoopUtil extends Logging {
225225 if (baseStatus.isDirectory) recurse(baseStatus) else Seq (baseStatus)
226226 }
227227
228+ /**
229+ * [LYFT-INTERNAL] Removed from OSS Spark: https://github.com/apache/spark/pull/40942/
230+ */
231+ def listLeafDirStatuses (fs : FileSystem , basePath : Path ): Seq [FileStatus ] = {
232+ listLeafDirStatuses(fs, fs.getFileStatus(basePath))
233+ }
234+
235+ /**
236+ * [LYFT-INTERNAL] Removed from OSS Spark: https://github.com/apache/spark/pull/40942/
237+ */
238+ def listLeafDirStatuses (fs : FileSystem , baseStatus : FileStatus ): Seq [FileStatus ] = {
239+ def recurse (status : FileStatus ): Seq [FileStatus ] = {
240+ val (directories, files) = fs.listStatus(status.getPath).partition(_.isDirectory)
241+ val leaves = if (directories.isEmpty) Seq (status) else Seq .empty[FileStatus ]
242+ leaves ++ directories.flatMap(dir => listLeafDirStatuses(fs, dir))
243+ }
244+
245+ assert(baseStatus.isDirectory)
246+ recurse(baseStatus)
247+ }
248+
228249 def isGlobPath (pattern : Path ): Boolean = {
229250 pattern.toString.exists(" {}[]*?\\ " .toSet.contains)
230251 }
You can’t perform that action at this time.
0 commit comments