Github user petermaxlee commented on a diff in the pull request:
https://github.com/apache/spark/pull/15235#discussion_r80594396
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/ListingFileCatalog.scala
---
@@ -82,73 +85,185 @@ class ListingFileCatalog(
* This is publicly visible for testing.
*/
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")
-
- val childStatuses = {
- try {
- val stats = fs.listStatus(path)
- if (pathFilter != null) stats.filter(f =>
pathFilter.accept(f.getPath)) else stats
- } catch {
- case _: FileNotFoundException =>
- logWarning(s"The directory $path was not found. Was it
deleted very recently?")
- Array.empty[FileStatus]
- }
- }
+ val files =
+ if (paths.length >=
sparkSession.sessionState.conf.parallelPartitionDiscoveryThreshold) {
+ ListingFileCatalog.listLeafFilesInParallel(paths, hadoopConf,
sparkSession)
+ } else {
+ ListingFileCatalog.listLeafFilesInSerial(paths, hadoopConf)
+ }
+
+ mutable.LinkedHashSet(files: _*)
+ }
+
+ override def equals(other: Any): Boolean = other match {
+ case hdfs: ListingFileCatalog => paths.toSet == hdfs.paths.toSet
+ case _ => false
+ }
+
+ override def hashCode(): Int = paths.toSet.hashCode()
+}
+
+
+object ListingFileCatalog extends Logging {
+
+ // `FileStatus` is Writable but not serializable. What make it worse,
somehow it doesn't play
--- End diff --
Moved
---
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]