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)
相关推荐
zhixingheyi_tian3 分钟前
spark-sql migration
大数据·sql·spark
YangYang9YangYan4 分钟前
2026大专大数据科学专业学数据分析的技术价值分析
大数据·数据挖掘·数据分析
weixin_470436855 分钟前
小程序留存工具大全
大数据
是垚不是土7 分钟前
ClaudeCode×Elasticsearch:服务日志查询的 AI 化落地实践
大数据·运维·人工智能·elasticsearch·云计算·jenkins
Tezign_space9 分钟前
Agentic AI vs Copilot:为什么企业AI需要从“辅助工具”升级为“核心协作者”
大数据·人工智能·copilot
流氓架构师11 分钟前
2026年实测:Gemini 3.1 Pro vs GPT-5.4 Pro,谁更强?国内免费访问方案
大数据·人工智能·gpt
云姜.14 分钟前
RabbitMQ 核心概念
分布式·rabbitmq
lalala_Zou14 分钟前
RabbitMQ如何保证消息可靠性
分布式·rabbitmq
Chan1617 分钟前
从生产到消费:Kafka 核心原理与实战指南
java·spring boot·分布式·spring·java-ee·kafka·消息队列
yzp-20 分钟前
Kafka 原子更新,精确一次消费 Exactly-Once --------- 学习笔记
分布式·学习·kafka