Apache spark parallelize调用中的numslice被随后的合并覆盖
我有以下代码:Apache spark parallelize调用中的numslice被随后的合并覆盖,apache-spark,pyspark,Apache Spark,Pyspark,我有以下代码: index = sc.parallelize(range(1000), 100) huge_rows = index.map(heavy_processing) schema = StructType([StructField('f1', BinaryType(), False), StructField('f2', BinaryType(), False)]) bbox2d_dataframe = spark.createDataFrame(huge_rows, schema
index = sc.parallelize(range(1000), 100)
huge_rows = index.map(heavy_processing)
schema = StructType([StructField('f1', BinaryType(), False), StructField('f2', BinaryType(), False)])
bbox2d_dataframe = spark.createDataFrame(huge_rows, schema)
bbox2d_dataframe = bbox2d_dataframe.coalesce(1)
bbox2d_dataframe.write.option("compression", "none").mode('overwrite').parquet('/tmp/huge/')
我希望将处理并行化为100个任务(因为在并行化调用中numSlices=100),
因此,重处理可以更好地并行化。
然而,我在SparkUI中只看到一项任务。原因可能是什么
这是意料之中的,因为您调用了
coalesce(1)
。根据,它将返回一个具有指定分区数的数据帧(在您的案例1中)。如果您希望繁重的\u处理
更加分散,但又想写出一个文件,那么请使用重新分区(1)
,这样它会引入一个随机边界,并将第一阶段保留为100个分区