Scala Aggregate聚合操作

Aggregate(zeroValue)(seqOp, combOp)

对于RDD{1,2,3,4},

Aggregate( (6, 5) )( (x, y) => (x._1 + y), (x._2 + 1), (x,y) => (x._1 + y._1, x._2 + y._2))

zeroValue既是seqOp的初始值,也是combOp的初始值

1. 执行seqOp

x = (6, 5) y = 1 => (7, 6)

x = (7, 6) y = 2 => (9, 7)

x = (9, 7) y = 3 => (12, 8)

x = (12, 8) y = 4 => (16, 9)

2. 执行combOp

x = (6, 5) y=(16, 9) => (22, 14)    

猜你喜欢

转载自blog.csdn.net/weixin_42129080/article/details/80687216
今日推荐