nerdexam
Huawei

H13-723_V2.0 · Question #17

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

The correct answer is C. Iines.fIatMap(_.spIit" "")).map(word => (word, 1)).reduceByKey(_ +_).print(). See the full explanation below for the reasoning.

Question

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

Options

  • AIines.flatMap(.split" "")).map(word => (word, 1)).reduce( +_).print()
  • BIines.flatMap(.split" "")).map(word => (word,word.Iength())).reduceByKey ( +_).print()
  • CIines.fIatMap(.spIit" "")).map(word => (word, 1)).reduceByKey( +_).print()
  • DIines.flatMap(.split" "")).flatMap(word => (word, 1)).groupByKey( +_).print()

How the community answered

(50 responses)
  • A
    12% (6)
  • B
    6% (3)
  • C
    78% (39)
  • D
    4% (2)

Community Discussion

No community discussion yet for this question.

Full H13-723_V2.0 Practice