Spark: Expansion of RDD(Key, List) to RDD(Key, Value)

后端 未结 2 1843
南笙
南笙 2020-12-19 16:43

So I have an RDD of something like this

RDD[(Int, List)]]

Where a single element in the RDD looks like

(1, List(1, 2, 3))
<         


        
相关标签:
2条回答
  • 2020-12-19 16:50

    And in Python (based on @seanowen's answer):

    rdd.flatMap(lambda x: map(lambda e: (x[0], e), x[1]))
    
    0 讨论(0)
  • 2020-12-19 17:11

    rdd.flatMap { case (key, values) => values.map((key, _)) }

    0 讨论(0)
提交回复
热议问题