给定一个成对的rdd,如何生成另一个具有相同键集的rdd,以及值的笛卡尔积(对于每个键)作为新值?
我的意思是:
//Given
(K1, V1)
(K1, V2)
(K2, W1)
(K2, W2)
//Want
(K1, (V1, V1))
(K1, (V1, V2))
(K1, (V2, V2))
(K2, (W1, W1))
(K2, (W1, W2))
(K2, (W2, W2))
//Note (V2, V1) and (W2, W1) are not required, but having them in the result is not a big deal either.
作为scala和spark的新手,我认为使用诸如 mapValues
. 我错过了一些神奇的功能吗?谢谢。
1条答案
按热度按时间0qx6xfy61#
把东西连起来: