0

I have two different JavaPairRdd one with Key1,value and the second one with key2,value . What I try to achieve is merge them but get only the items with the same value.

I have tried the following:

 JavaPairRDD<String, String> finalRdd = filteredRdd.intersection(filteredsmallRdd);

Where filteredRdd contains key:Country , value and filteredsmallRdd contains: key:id , value . and I need which elements have the same value , with intersection i think that compare the only the key and I got an empty solution , any idea of how to do that?

KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
Aikas91
  • 15
  • 5

1 Answers1

0

You can use swap to change the value as the key for each of the rdd and then perform the intersection.

JavaPairRDD<String,String> finalRdd = filteredRdd.mapToPair(f -> f.swap()).intersection(filteredsmallRdd.mapToPair(f -> f.swap()));
Amit Kumar
  • 1,544
  • 11
  • 23