简体   繁体   English

如何加入两个特殊的RDD?

[英]How to join two special RDDs?

One is 一个是

rdd1 : JavaPairRDD<Tuple2<String,String>,Integer> 

another is 另一个是

rdd2 : JavaPairRDD<String,Integer>

I want to join rdd1 and rdd2 where Tuple2._1 in rdd1 equals to the key in rdd2. 我想加入rdd1和rdd2,其中rdd1中的Tuple2._1等于rdd2中的键。 For example, (("a","b"),1) and ("a",2) will generate (("a","b"),1,2). 例如,(((“ a”,“ b”),1)和(“ a”,2)将生成((“ a”,“ b”),1,2)。 When I map rdd1 to: 当我将rdd1映射到:

rdd3 : JavaPairRDD<String, Tuple2<String, Integer>>

and try to use rdd3.join(rdd2) , it arose “can only concatenate tuple (not "str") to tuple”. 并尝试使用rdd3.join(rdd2),它出现了“只能将元组(不是“ str”)连接到元组”。 Is there a solution to join rdd1 and rdd2 and get the results I want? 是否有加入rdd1和rdd2并获得我想要的结果的解决方案?

Map rdd1 to: 将rdd1映射到:

JavaPairRDD<String, Tuple2<Tuple2<String,String>,Integer>>

with something like: 与类似:

x -> new Tuple2(x._1._1, x)

use standard join and map once again to have desired result 使用标准联接并再次映射以获得所需结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM