Spark 之 partitons

Listing leaf files and directories

分析其并行化

org.apache.spark.util.HadoopFSUtils

复制代码
      sc.parallelize(paths, numParallelism)
        .mapPartitions { pathsEachPartition =>
          val hadoopConf = serializableConfiguration.value
          pathsEachPartition.map { path =>
            val leafFiles = listLeafFiles(
              path = path,
              hadoopConf = hadoopConf,
              filter = filter,
              contextOpt = None, // Can't execute parallel scans on workers
              ignoreMissingFiles = ignoreMissingFiles,
              ignoreLocality = ignoreLocality,
              isRootPath = isRootLevel,
              parallelismThreshold = Int.MaxValue,
              parallelismMax = 0)
            (path, leafFiles)
          }
        }.collect()

    // Set the number of parallelism to prevent following file listing from generating many tasks
    // in case of large #defaultParallelism.
    val numParallelism = Math.min(paths.size, parallelismMax)

parallelismMax 最终由以下配置决定。

复制代码
  val PARALLEL_PARTITION_DISCOVERY_PARALLELISM =
    buildConf("spark.sql.sources.parallelPartitionDiscovery.parallelism")
      .doc("The number of parallelism to list a collection of path recursively, Set the " +
        "number to prevent file listing from generating too many tasks.")
      .version("2.1.1")
      .internal()
      .intConf
      .createWithDefault(10000)
相关推荐
V_156560272197 分钟前
第一批!2026年陕西省科技攻关项目申报时间条件程序
大数据·人工智能·科技
回家路上绕了弯11 分钟前
线程池拒绝策略为何不一致?项目实战中的决策逻辑与踩坑指南
分布式·后端
武子康15 分钟前
大数据-171 Elasticsearch-Head 与 Kibana 7.3.0 实战:安装要点、连通性与常见坑
大数据·后端·elasticsearch
阿萨德528号19 分钟前
Kafka定理剖析:分区数要大于消费者数
分布式·kafka
第一启富金加盟中心23 分钟前
香港第一金现货黄金操作建议2025-12-1
大数据·人工智能·金融·业界资讯
明达智控技术34 分钟前
MR30分布式IO赋能注塑机智能化升级
分布式·物联网·自动化
ManageEngineITSM35 分钟前
把问题“消灭在未来”:IT 资产管理软件与问题管理的深度融合逻辑
大数据·运维·人工智能·itsm·工单系统
智元视界39 分钟前
从深度学习到自主学习:AI的下一个技术跃迁
大数据·人工智能·深度学习·学习·架构·数字化转型·产业升级
一只游鱼42 分钟前
spark3版本和java17版本不兼容导致的报错解决方法
spark