How do I iterate RDD's in apache spark (scala)

后端 未结 5 1650
遇见更好的自我
遇见更好的自我 2020-12-01 01:52

I use the following command to fill an RDD with a bunch of arrays containing 2 strings [\"filename\", \"content\"].

Now I want to iterate over every of those occurre

5条回答
  •  醉酒成梦
    2020-12-01 02:18

    for (element <- YourRDD)
    {
         // do what you want with element in each iteration, and if you want the index of element, simply use a counter variable in this loop beginning from 0 
         println (element._1) // this will print all filenames
    }
    

提交回复
热议问题