You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by steveloughran <gi...@git.apache.org> on 2016/07/26 12:55:18 UTC

[GitHub] spark pull request #13830: [SPARK-16121] ListingFileCatalog does not list in...

Github user steveloughran commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13830#discussion_r72242750
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/ListingFileCatalog.scala ---
    @@ -73,21 +73,67 @@ class ListingFileCatalog(
         cachedPartitionSpec = null
       }
     
    -  protected def listLeafFiles(paths: Seq[Path]): mutable.LinkedHashSet[FileStatus] = {
    +  /**
    +   * List leaf files of given paths. This method will submit a Spark job to do parallel
    +   * listing whenever there is a path having more files than the parallel partition discovery
    +   * discovery threshold.
    +   */
    +  protected[spark] def listLeafFiles(paths: Seq[Path]): mutable.LinkedHashSet[FileStatus] = {
         if (paths.length >= sparkSession.sessionState.conf.parallelPartitionDiscoveryThreshold) {
           HadoopFsRelation.listLeafFilesInParallel(paths, hadoopConf, sparkSession)
         } else {
    +      // Right now, the number of paths is less than the value of
    +      // parallelPartitionDiscoveryThreshold. So, we will list file statues at the driver.
    +      // If there is any child that has more files than the threshold, we will use parallel
    +      // listing.
    +
           // Dummy jobconf to get to the pathFilter defined in configuration
           val jobConf = new JobConf(hadoopConf, this.getClass)
           val pathFilter = FileInputFormat.getInputPathFilter(jobConf)
    +
           val statuses: Seq[FileStatus] = paths.flatMap { path =>
             val fs = path.getFileSystem(hadoopConf)
             logTrace(s"Listing $path on driver")
    -        Try {
    -          HadoopFsRelation.listLeafFiles(fs, fs.getFileStatus(path), pathFilter)
    -        }.getOrElse(Array.empty[FileStatus])
    +
    +        val childStatuses = {
    +          // TODO: We need to avoid of using Try at here.
    +          val stats = Try(fs.listStatus(path)).getOrElse(Array.empty[FileStatus])
    +          if (pathFilter != null) stats.filter(f => pathFilter.accept(f.getPath)) else stats
    +        }
    +
    +        childStatuses.map {
    +          case f: LocatedFileStatus => f
    +
    +          // NOTE:
    +          //
    +          // - Although S3/S3A/S3N file system can be quite slow for remote file metadata
    +          //   operations, calling `getFileBlockLocations` does no harm here since these file system
    +          //   implementations don't actually issue RPC for this method.
    +          //
    --- End diff --
    
    while you are correct about s3a, the openstack swift client does do RPC here, as swift instances can exhibit locality, as does Azure. This comment isn't actually correct.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org