How to flatten a collection with Spark/Scala?

前端 未结 2 910
时光取名叫无心
时光取名叫无心 2020-12-09 09:38

In Scala I can flatten a collection using :

val array = Array(List(\"1,2,3\").iterator,List(\"1,4,5\").iterator)
                                                    


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 10:05

    Use flatMap and the identity Predef, this is more readable than using x => x, e.g.

    myRdd.flatMap(identity)
    

提交回复
热议问题