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)
相关推荐
GIS数据转换器1 小时前
智慧林草“一张图“平台
java·大数据·服务器·前端·javascript·数据库·人工智能
whcyhhh2 小时前
头歌实践教学平台:数据科学与大数据技术导论(十四)
大数据·开发语言·python
Hrain-AI2 小时前
企业 AI 治理运营怎么做:分级授权、Token 用量可观测与模型统一纳管
大数据·人工智能·算法
lhldsg2 小时前
线上住宿预约系统开发实战:从需求分析到接口设计
java·大数据·小程序·需求分析
江苏赛融科技3 小时前
数据驱动:能耗管理系统如何将能源数据转化为管理决策资产
大数据·人工智能·能源·智慧园区·企业资产管理·园区智能化
AI智图坊3 小时前
宠物用品电商视觉内容生产的技术难点与自动化方案分析
大数据·运维·人工智能·ai作画·自动化·aigc
陕西企来客3 小时前
2026年8月真实安装案例:门窗现场施工到完工记录
大数据·运维·真实安装案例
财迅通Ai3 小时前
TCL中环2026年中报大幅减亏,一体化与全球化共同驱动经营改善
大数据·人工智能·tcl中环
MetaLite3 小时前
Spring-Scheduled多实例重复执行怎么办-Redis分布式锁如何只让一个节点运行
redis·分布式·spring