pirox22
pirox22

Reputation: 922

Convert JavaPairRdd to JavaRdd by concatenating key and value

I am new to Apache Spark. As the title says, I have a JavaPairRdd<String,String> and I want to produce a JavaRdd<String> with the concatenation of the key and the value of the JavaPairRdd. Is this possible?

Example:

("1,Nick", "[email protected],53")
("2,John", "[email protected],53")

Result (JavaRdd<String> with):

"1,Nick,[email protected],53"
"2,John,[email protected],53"

Upvotes: 0

Views: 1076

Answers (1)

Justin Pihony
Justin Pihony

Reputation: 67065

Just use a map:

pairRDD.map((key, value) => key + value)

That is using scala, but you should get the gist.

Upvotes: 1

Related Questions