且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过键连接两个RDDS得到(字符串,字符串)的RDD?

更新时间:2022-11-17 12:26:18

正如你可能会从名称按键猜协同组团体的意见。这意味着,你的情况你会得到:

As you might guess from the name cogroup groups observations by key. It means that in your case you get:

(String, (Iterable[mutable.HashSet[String]], Iterable[mutable.HashSet[String]]))

不是

(String, (mutable.HashSet[String], mutable.HashSet[String]))

当你看看你的错误是pretty清楚。如果您想对组合你应该使用加入方法。如果没有,你应该调整模式来匹配结构,你再使用这样的:

It is pretty clear when you take a look at the error you get. If you want to combine pairs you should use join method. If not you should adjust pattern to match structure you get and then use something like this:

val combinedhs = value1.reduce(_ ++ _) ++ value2.reduce(_ ++ _)