2017-04-20 59 views
-1

我有下面的一个文件的“#”分裂之后,多个拆分和地图在星火

res64: Array[(String, String)] = Array((1,Animation|Children's|Comedy), (2,Adventure|Children's|Fantasy)) 

如何获得(使用不同的)像(1, Animation),(1,Children's)等。唯一的一对,每key(电影ID在这里)像RDD中的1?

回答

0

可以简单如

rdd.mapValues(x => x.split('|'))\ 
.flatMapValues(x=>x)\ 
.distinct()\ 
.collect()