
复制object WordCount { def main(args: Array[String]) { if (args.length <2) { System.err.println("Usage: WordCount <inputfile><outputfile>"); System.exit(1); } val conf = new SparkConf().setAppName("WordCount") val sc = new SparkContext(conf) val result = sc.textFile(args(0)) .flatMap(line => line.split(" ")) .map(word => (word,核多少
1)) .reduceByKey(_ + _) result.saveAsTextFile(args(1)) } } 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.