用這裏的wordCount代碼,在spark-shell上運行html
scala$ spark-shell scala> val file = sc.textFile("<input file>") scala> val counts = file.flatMap(line => line.split(" ")).map(word => (word, 1)).reduceByKey(_ + _) scala> counts.saveAsTextFile("<output file>")
能夠在<output file>/part-00000
(可能不僅一個輸出結果文件)中看到結果shell