You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/04/01 02:49:03 UTC

[GitHub] [spark] ConeyLiu commented on a change in pull request #24237: [SPARK-27319][SQL] Filter out dir based on PathFilter before listing them

ConeyLiu commented on a change in pull request #24237: [SPARK-27319][SQL] Filter out dir based on PathFilter before listing them
URL: https://github.com/apache/spark/pull/24237#discussion_r270704276
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala
 ##########
 @@ -167,36 +167,39 @@ object InMemoryFileIndex extends Logging {
       hadoopConf: Configuration,
       filter: PathFilter,
       sparkSession: SparkSession): Seq[(Path, Seq[FileStatus])] = {
+    // Filter out the directory before listing it leaf files
+    val filteredPaths = paths.filter(filter.accept(_))
 
     // Short-circuits parallel listing when serial listing is likely to be faster.
-    if (paths.size <= sparkSession.sessionState.conf.parallelPartitionDiscoveryThreshold) {
-      return paths.map { path =>
+    if (filteredPaths.size <= sparkSession.sessionState.conf.parallelPartitionDiscoveryThreshold) {
 
 Review comment:
   No, the PathFilter is applied on a path, not on the leaf file paths. The path can be file or directory. > Is the use case just setting a filter to apply an operation to a subset of dirs?
   
   just as I described in the pr or in the UT test.
   
   > why not filter them out at the caller level?
   
   Configuration should be more flexible. Otherwise, people may need to filter in the user code. Maybe we can add another option in the datafram reader if we must filter by the user code directly.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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