问题
I got:
val vector: RDD[(String, HashMap[String,Double])] = [("a", {("x",1.0),("y", 2.0),...}]
I want to get:
RDD[String,(String,Double)] = [("a",("x",1.0)), ("a", ("y", 2.0)), ...]
How can it be done with FlatMap? Better solutions are welcome!
回答1:
Try:
vector.flatMapValues(_.toSeq)
来源:https://stackoverflow.com/questions/38507249/apache-spark-scala-hashmap-k-hashmapstring-doublev1-v2-to-k-v1