Github user kiszk commented on a diff in the pull request:
https://github.com/apache/spark/pull/18269#discussion_r122199265
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala
---
@@ -248,60 +245,92 @@ object InMemoryFileIndex extends Logging {
* @return all children of path that match the specified filter.
*/
private def listLeafFiles(
- path: Path,
+ paths: Seq[Path],
hadoopConf: Configuration,
filter: PathFilter,
- sessionOpt: Option[SparkSession]): Seq[FileStatus] = {
- logTrace(s"Listing $path")
- val fs = path.getFileSystem(hadoopConf)
+ sessionOpt: Option[SparkSession]): Seq[(Path, Seq[FileStatus])] = {
+ logTrace(s"Listing ${paths.mkString(", ")}")
+ val fs = paths.headOption.map(_.getFileSystem(hadoopConf))
// [SPARK-17599] Prevent InMemoryFileIndex from failing if path
doesn't exist
// Note that statuses only include FileStatus for the files and dirs
directly under path,
// and does not include anything else recursively.
- val statuses = try fs.listStatus(path) catch {
- case _: FileNotFoundException =>
- logWarning(s"The directory $path was not found. Was it deleted
very recently?")
- Array.empty[FileStatus]
+ val statuses = paths.flatMap { path =>
+ try {
+ Some(path -> fs.get.listStatus(path))
+ } catch {
+ case _: FileNotFoundException =>
+ logWarning(s"The directory $paths was not found. Was it deleted
very recently?")
+ None
+ }
}
- val filteredStatuses = statuses.filterNot(status =>
shouldFilterOut(status.getPath.getName))
+ val filteredStatuses = statuses.flatMap { case (path, fStatuses) =>
+ val filtered = fStatuses.filterNot(status =>
shouldFilterOut(status.getPath.getName))
+ if (filtered.isEmpty) {
--- End diff --
nit: this block should be moved to left with 2 spaces
---
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]