📜  聚合每个分区的元素,然后聚合所有分区的结果 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:02.981000             🧑  作者: Mango

代码示例1
#Aggregate the elements of each partition, and then the results for all the partitions

seqOp = (lambda x, y: (x[0] + y, x[1] + 1))
combOp = (lambda x, y: (x[0] + y[0], x[1], y[1]))
sc.parallelize([1, 2, 3, 4]).aggregate((0, 0), seqOp, combOp)
# (10, 4)
sc.parallelize([]).aggregate((0, 0), seqOp, combOp)
# (0, 0)