[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user asfgit closed the pull request at: https://github.com/apache/spark/pull/18269 --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/18269#discussion_r122622206 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala --- @@ -248,60 +245,94 @@ 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) - -// [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 filteredStatuses = statuses.filterNot(status => shouldFilterOut(status.getPath.getName)) + sessionOpt: Option[SparkSession]): Seq[(Path, Seq[FileStatus])] = { +logTrace(s"Listing ${paths.mkString(", ")}") +if (paths.isEmpty) { + Nil +} else { + val fs = paths.head.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 filteredStatuses = paths.flatMap { path => +try { + val fStatuses = fs.listStatus(path) + val filtered = fStatuses.filterNot(status => shouldFilterOut(status.getPath.getName)) + if (filtered.nonEmpty) { +Some(path -> filtered) + } else { +None + } +} catch { + case _: FileNotFoundException => +logWarning(s"The directory $paths was not found. Was it deleted very recently?") +None +} + } -val allLeafStatuses = { - val (dirs, topLevelFiles) = filteredStatuses.partition(_.isDirectory) - val nestedFiles: Seq[FileStatus] = sessionOpt match { -case Some(session) => - bulkListLeafFiles(dirs.map(_.getPath), hadoopConf, filter, session).flatMap(_._2) -case _ => - dirs.flatMap(dir => listLeafFiles(dir.getPath, hadoopConf, filter, sessionOpt)) + val allLeafStatuses = { +val (dirs, topLevelFiles) = filteredStatuses.flatMap { case (path, fStatuses) => + fStatuses.map { f => path -> f } +}.partition { case (_, fStatus) => fStatus.isDirectory } +val pathsToList = dirs.map { case (_, fStatus) => fStatus.getPath } +val nestedFiles = if (pathsToList.nonEmpty) { + sessionOpt match { +case Some(session) => + bulkListLeafFiles(pathsToList, hadoopConf, filter, session) +case _ => + listLeafFiles(pathsToList, hadoopConf, filter, sessionOpt) + } +} else Seq.empty[(Path, Seq[FileStatus])] +val allFiles = topLevelFiles.groupBy { case (path, _) => path } --- End diff -- nit: `xxx.groupBy(_._1)` --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/18269#discussion_r122622157 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala --- @@ -248,60 +245,94 @@ 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) - -// [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 filteredStatuses = statuses.filterNot(status => shouldFilterOut(status.getPath.getName)) + sessionOpt: Option[SparkSession]): Seq[(Path, Seq[FileStatus])] = { +logTrace(s"Listing ${paths.mkString(", ")}") +if (paths.isEmpty) { + Nil +} else { + val fs = paths.head.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 filteredStatuses = paths.flatMap { path => +try { + val fStatuses = fs.listStatus(path) + val filtered = fStatuses.filterNot(status => shouldFilterOut(status.getPath.getName)) + if (filtered.nonEmpty) { +Some(path -> filtered) + } else { +None + } +} catch { + case _: FileNotFoundException => +logWarning(s"The directory $paths was not found. Was it deleted very recently?") +None +} + } -val allLeafStatuses = { - val (dirs, topLevelFiles) = filteredStatuses.partition(_.isDirectory) - val nestedFiles: Seq[FileStatus] = sessionOpt match { -case Some(session) => - bulkListLeafFiles(dirs.map(_.getPath), hadoopConf, filter, session).flatMap(_._2) -case _ => - dirs.flatMap(dir => listLeafFiles(dir.getPath, hadoopConf, filter, sessionOpt)) + val allLeafStatuses = { +val (dirs, topLevelFiles) = filteredStatuses.flatMap { case (path, fStatuses) => + fStatuses.map { f => path -> f } +}.partition { case (_, fStatus) => fStatus.isDirectory } +val pathsToList = dirs.map { case (_, fStatus) => fStatus.getPath } +val nestedFiles = if (pathsToList.nonEmpty) { --- End diff -- do we need this `if` check? --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/18269#discussion_r122622031 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala --- @@ -248,60 +245,94 @@ 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) - -// [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 filteredStatuses = statuses.filterNot(status => shouldFilterOut(status.getPath.getName)) + sessionOpt: Option[SparkSession]): Seq[(Path, Seq[FileStatus])] = { +logTrace(s"Listing ${paths.mkString(", ")}") +if (paths.isEmpty) { + Nil +} else { + val fs = paths.head.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 filteredStatuses = paths.flatMap { path => +try { + val fStatuses = fs.listStatus(path) + val filtered = fStatuses.filterNot(status => shouldFilterOut(status.getPath.getName)) + if (filtered.nonEmpty) { +Some(path -> filtered) + } else { +None + } +} catch { + case _: FileNotFoundException => +logWarning(s"The directory $paths was not found. Was it deleted very recently?") +None +} + } -val allLeafStatuses = { - val (dirs, topLevelFiles) = filteredStatuses.partition(_.isDirectory) - val nestedFiles: Seq[FileStatus] = sessionOpt match { -case Some(session) => - bulkListLeafFiles(dirs.map(_.getPath), hadoopConf, filter, session).flatMap(_._2) -case _ => - dirs.flatMap(dir => listLeafFiles(dir.getPath, hadoopConf, filter, sessionOpt)) + val allLeafStatuses = { +val (dirs, topLevelFiles) = filteredStatuses.flatMap { case (path, fStatuses) => + fStatuses.map { f => path -> f } +}.partition { case (_, fStatus) => fStatus.isDirectory } --- End diff -- nit: `xxx.partition(_._2. isDirectory)` --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/18269#discussion_r122621941 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala --- @@ -248,60 +245,94 @@ 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) - -// [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 filteredStatuses = statuses.filterNot(status => shouldFilterOut(status.getPath.getName)) + sessionOpt: Option[SparkSession]): Seq[(Path, Seq[FileStatus])] = { +logTrace(s"Listing ${paths.mkString(", ")}") +if (paths.isEmpty) { + Nil +} else { + val fs = paths.head.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 filteredStatuses = paths.flatMap { path => +try { + val fStatuses = fs.listStatus(path) + val filtered = fStatuses.filterNot(status => shouldFilterOut(status.getPath.getName)) + if (filtered.nonEmpty) { --- End diff -- nit: `filtered.map(path -> _)`, so that we don't need the `if-else` here, and the `flatMap` [there](https://github.com/apache/spark/pull/18269/files?diff=split#diff-95dcbab8e4f960b101c8a6b7a05fdc2fR278) --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/18269#discussion_r121843329 --- 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) => --- End diff -- something like ``` paths.flatMap { path => try { val status = fs.get.listStatus(path) val filteredStatuses = statuses.filterNot(status => shouldFilterOut(status.getPath.getName)) } catch ... } ``` --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/18269#discussion_r121843352 --- 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) => --- End diff -- then we can still keep the previous code structure --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/18269#discussion_r121843175 --- 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) => --- End diff -- can we merge these `flatMaps`? --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/18269#discussion_r121843022 --- 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)) --- End diff -- how about ``` if (paths.isEmpty) { Nil } else { val fs = paths.head.getFileSystem(hadoopConf) .. } ``` --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user bbossy commented on a diff in the pull request: https://github.com/apache/spark/pull/18269#discussion_r121316195 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala --- @@ -248,60 +245,93 @@ 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(", ")}") // [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 { +val fs = path.getFileSystem(hadoopConf) --- End diff -- Thanks! Fixed. --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user srowen commented on a diff in the pull request: https://github.com/apache/spark/pull/18269#discussion_r121286974 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala --- @@ -248,60 +245,93 @@ 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(", ")}") // [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 { +val fs = path.getFileSystem(hadoopConf) --- End diff -- Yes, it's the same instance and should be reused --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
Github user bbossy commented on a diff in the pull request: https://github.com/apache/spark/pull/18269#discussion_r121279679 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala --- @@ -248,60 +245,93 @@ 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(", ")}") // [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 { +val fs = path.getFileSystem(hadoopConf) --- End diff -- Would it be safe to use the same instance of `fs` for all the paths in a InMemoryFileIndex? If this is the case, I can move this back to where it was before. --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #18269: [SPARK-21056][SQL] Use at most one spark job to l...
GitHub user bbossy opened a pull request: https://github.com/apache/spark/pull/18269 [SPARK-21056][SQL] Use at most one spark job to list files in InMemoryFileIndex ## What changes were proposed in this pull request? This PR changes `InMemoryFileIndex.listLeafFiles` behaviour to launch at most one spark job to list leaf files. ## How was this patch tested? Adapted existing tests to match expected behaviour. You can merge this pull request into a Git repository by running: $ git pull https://github.com/bbossy/spark SPARK-21056 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/18269.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #18269 commit 9a6b92bd58afdf373aac98702beb8d1d6eea6b57 Author: Bertrand BossyDate: 2017-06-11T11:37:29Z SPARK-21056: use at most one spark job to list files in InMemoryFileIndex --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org