Zhang SAN
Li si
Zhang xiao
Hu xi
.
The text is analyzed with the Spark, and the output contains the number of the same surname,
Such as: zhang li hu 1 2 1
CodePudding user response:
Wordcount official case modification is ok, a little wordcout is to get all the words, you just get the first wordCodePudding user response:
[code=scala]Val RDD=sc. Parallelize (Array (" zhang SAN ", "li si", "zhang xiao", "hu xi"))
Val xing=RDD. The map (name=& gt; (the name. The split (" ") (0), 1))
Val CNT=xing. ReduceByKey (+ _ _)
CNT. Collect. Foreach (t=& gt; Println (" s "${t. _1} : ${t. _2}"))
[/code]
What's the problem? Are you for
CNT. Foreach (t=& gt; Println (" s "${t. _1} : ${t. _2}"))
Have no reaction, so they think that failed?
Because the println is occurred on the executor, unless you choose to master=local [*], that will be in the machine to print