leovegas commented on code in PR #46678:
URL: https://github.com/apache/spark/pull/46678#discussion_r1619210351


##########
core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala:
##########
@@ -218,12 +218,17 @@ private[spark] class SparkHadoopUtil extends Logging {
    * that file.
    */
   def listLeafStatuses(fs: FileSystem, baseStatus: FileStatus): 
Seq[FileStatus] = {
-    def recurse(status: FileStatus): Seq[FileStatus] = {
-      val (directories, leaves) = 
fs.listStatus(status.getPath).partition(_.isDirectory)
-      (leaves ++ directories.flatMap(f => listLeafStatuses(fs, 
f))).toImmutableArraySeq
+    val locatedFileStatusIt = fs.listFiles(baseStatus.getPath, true)
+    getFileStatusSeq(locatedFileStatusIt)
+  }
+
+  private[spark] def getFileStatusSeq(ri: RemoteIterator[LocatedFileStatus]): 
Seq[FileStatus] = {
+    val scalaIterator: Iterator[LocatedFileStatus] = new 
Iterator[LocatedFileStatus] {
+      override def hasNext: Boolean = ri.hasNext
+      override def next(): LocatedFileStatus = ri.next()
     }
 
-    if (baseStatus.isDirectory) recurse(baseStatus) else Seq(baseStatus)
+    scalaIterator.toSeq.map(identity)

Review Comment:
   to convert a Seq[LocatedFileStatus] to Seq[FileStatus] without changing the 
elements. Anything wrong with that?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to