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 03:20:07 UTC

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

srowen 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_r270707388
 
 

 ##########
 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:
   Right now, it's only applied to the full path of what is listed by the 'leaf file' methods. I'm not sure what you mean here by leaf file path then. The point is to _also_ apply it to the path of parent dirs earlier, right?
   
   I think the use case could be made clearer. I'm guessing it's something like this:
   
   You want to read a subset of all `hdfs://name:port/root-dir/timestamp=yyyy-MM-dd/xxx.csv` files for example. You only want to read, say, `hdfs://name:port/root-dir/timestamp=2019-MM-dd/xxx.csv` files really. You pass a filter that matches something like `*2019-MM-dd*` and use all the `hdfs://name:port/root-dir/timestamp=yyyy-MM-dd` directories as the data paths. It has to list all the `hdfs://name:port/root-dir/timestamp=yyyy-MM-dd` paths before it can figure out that lots are filtered out and never had to be listed.
   
   If that's the case, that seems a lot easier to filter in user code. Is the use case different or more complex?
   
   I'm trying to weigh the problem with the behavior change against a realistic use case that would benefit.

----------------------------------------------------------------
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