Questions to the spark streaming with Scala

I know this is nothing about scala, but a spark related question. But I got no helps from the spark community so I ask the question here. Thank you for all the kind helps.

For this streaming client by scala, I have two questions:

  1. Why enclose the translation of RDD to Dataframe into the foreachRDD block? I don’t see what’s the use of foreachRDD method.
  2. Why use a singleton for getting a spark sesson? in my before experience I never use singleton for this purpose.

Thank you.

After the testing I know the use of foreachRDD, here RDD means each batch (the structure is a RDD) in the streaming.
So, how about that singleton definition?

Thanks.