In Spark, assuming that lines is a DStream object, which of the following statements can periodically count the number of words on this stream?

In Spark, assuming that lines is a DStream object, which of the following statements can periodically count the number of words on this stream?
A . Iines.flatMap(_.split ” “” )).map(word => (word, 1)).reduce(_ +_).print()
B . Iines.flatMap(_.split ” “” )).map(word => (word,word.Iength())).reduceByKey (_ +_).print()
C . Iines.fIatMap(_.spIit ” “” )).map(word => (word, 1)).reduceByKey(_ +_).print()
D . Iines.flatMap(_.split ” “” )).flatMap(word => (word, 1)).groupByKey(_ +_).print()

Answer: C

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments