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)
相关推荐
ly768919 分钟前
Elasticsearch 写入链路的 refresh、flush 与 translog 边界:为什么 bulk 吞吐会突然塌陷
大数据·elasticsearch·搜索引擎·translog·写入链路·bulk调优
python与大数据分析37 分钟前
大模型 or Not?智慧农业落地,大小模型各有所长
大数据·人工智能
珠海西格电力1 小时前
AI预测与优化:基于机器学习的负荷预测与调度策略
大数据·人工智能·机器学习·信息可视化·架构·能源
HZZD_HZZD1 小时前
商场餐饮铺基本电费怎么算?需量控制与峰值申报
大数据·物联网·腾讯云
wengad2 小时前
嵌入式金融数据上链:挑战、核心问题与解决方案
大数据·金融·区块链·金融创新
starzy19902 小时前
Flink ResourceManager启动流程源码深度剖析:从ClusterEntrypoint到Slot分配的完整链路
java·大数据·flink
Sayai2 小时前
ClickHouse WITH FILL 实战:监控大屏时间序列补零,附多粒度指标表与物化视图级联设计
大数据·运维·数据仓库·clickhouse·物化视图
2603_954708312 小时前
微能网的核心硬件协调控制装置有哪些功能?
大数据·运维·人工智能·架构·能源
T06205142 小时前
【工具变量】“国家级大数据综合试验区”政策试点DID(2000-2025年)
大数据
samFuB2 小时前
【数据集】A股上市企业劳动雇佣与稳就业数据(dta+xlsx)2010-2024年
大数据