做seo学网站,高清免费素材网站,wordpress弹出搜索,整容网站模板源码
parquet文件读取的入口是FileSourceScanExec#xff0c;用parquet文件生成对应的RDD
非bucket文件所以走createNonBucketedReadRDD方法。 createNonBucketedReadRDD
过程#xff1a;
确定文件分割参数 openCostInBytes4M 相关参数spark.sql.files.openCostInBytes4M…源码
parquet文件读取的入口是FileSourceScanExec用parquet文件生成对应的RDD
非bucket文件所以走createNonBucketedReadRDD方法。 createNonBucketedReadRDD
过程
确定文件分割参数 openCostInBytes4M 相关参数spark.sql.files.openCostInBytes4MmaxSplitBytes128M 相关参数spark.sql.files.maxPartitionBytes128M根据maxSplitBytes计算得来logInfo打印的日志可以用于排查参数 切分文件 splitFiles进行文件切分按照maxSplitBytes将大文件切分 切分后文件根据大小进行倒排为了方便后面合并合并partition getFilePartitions 将小文件合并到一个partition 生成RDD maxSplitBytes
defaultMaxSplitBytes 最大分区大小spark.sql.files.maxPartitionBytes128MopenCostInBytes 打开文件的代价 默认4MdefaultParallelism 并行度conf.getInt(spark.default.parallelism, math.max(totalCoreCount.get(), 2)) 默认是core的总和最小为2totalBytes 文件总大小单个文件大小需要加上openCostInBytesbytesPerCore 单个core分配的文件大小
最后Math.min(defaultMaxSplitBytes, Math.max(openCostInBytes, bytesPerCore)) splitFiles
0L until file.getLen by maxSplitBytes按maxSplitBytes进行文件拆分 getFilePartitions
currentSize file.length openCostInBytes计算文件大小的时候需要加上openCostInBytes 计算示例
parquet文件是9,905,218b并行度是2 defaultMaxSplitBytes 128MB
openCostInBytes 4MB
defaultParallelism max(2, 2) 2
totalBytes 9,905,218b 1 * 4MB 14,099,522B
bytesPerCore 14,099,522B / 2 7,049,761B
maxSplitBytes 7,049,761B Math.min(defaultMaxSplitBytes, Math.max(openCostInBytes, bytesPerCore))
文件分成0-7049761 和 7049761-9905218两部分
从下面日志可以知道计算正确。 参考https://developer.aliyun.com/article/985412?utm_contentm_1000349867