How to convert an Iterable to an RDD
You can achieve this by using a flatMap
and reduceByKey
. Something like this:
rdd.flatMap{case(key, list) => list.map(item => ((key,item._1), item._2))} .reduceByKey(_+_) .map{case((key,name),hours) => (key, List((name, hours)))} .reduceByKey(_++_)