existSpark, assuminglinesIs anDStreamobject, which of the following statements can periodically count this number of words on a stream?
lines.flatMap(_.split(" ")).map(word =>(word,1)).reduce(_+_).print( )
lines.flatMap(_.split(" ")).map(word =>(word,word.length())).reduceByKey
(_+_).print( )
lines.flatMap(_.split(" ")).map(word =>(word,1)).reduceByKey(_+_).print
( )
lines.flatMap(_.split(" ")).flatmap(word =>(word,1)).groupByKey(_+_).print
Submit