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)
相关推荐
清辞8534 分钟前
Coze从入门到实战---第一、二章
大数据·人工智能·学习·语言模型
TomatoStudy26 分钟前
IT职业教育AI落地与实训体系建设复盘——以职坐标模式为例
大数据·人工智能
半夜修仙40 分钟前
RabbitMQ中如何保证消息的可靠性传输
java·分布式·中间件·rabbitmq·github·java-rabbitmq
Java 码思客1 小时前
【ElasticSearch从入门到架构师】第1章:ElasticSearch 核心认知与行业定位
大数据·elasticsearch·搜索引擎
cui17875681 小时前
物业费收缴困局的破题之路:2026年社区商业逻辑的底层重构
大数据·数据库·人工智能
2501_933670791 小时前
大数据在校实训项目一般做什么类型内容
大数据
monsion2 小时前
Loop Engineering:你不再 prompt agent,而是设计 prompt agent 的系统
大数据·人工智能·prompt
保卫大狮兄2 小时前
什么是WBS项目管理?WBS有哪些核心功能?
大数据·人工智能
标书畅畅行2 小时前
钛投标:全流程企业级AI标书解决方案,重构投标数字化生产力
大数据·人工智能
2601_954971133 小时前
2026年大数据专业证书报考指南
大数据