This commit is contained in:
罗祥
2019-05-15 08:52:35 +08:00
parent beb52978b7
commit a94cac32e6
9 changed files with 28 additions and 13 deletions

View File

@ -1 +0,0 @@
(mapreduce,1)

View File

@ -1,2 +0,0 @@
(spark,2)
(hadoop,2)

View File

@ -3,14 +3,12 @@ package com.heibaiying.spark.rdd
import org.apache.spark.{SparkConf, SparkContext}
object WordCount {
object WordCount extends App {
def main(args: Array[String]): Unit = {
val conf = new SparkConf().setAppName("sparkBase").setMaster("local[2]")
val sc = new SparkContext(conf)
val rdd = sc.textFile("input/wc.txt").flatMap(_.split(",")).map((_, 1)).reduceByKey(_ + _)
rdd.foreach(println)
rdd.saveAsTextFile("output/")
}
val conf = new SparkConf().setAppName("sparkBase").setMaster("local[2]")
val sc = new SparkContext(conf)
val rdd = sc.textFile("input/wc.txt").flatMap(_.split(",")).map((_, 1)).reduceByKey(_ + _)
rdd.foreach(println)
rdd.saveAsTextFile("output/")
}