标签:error log4 contex obj 代码 file master atm nbsp
代码:
import org.apache.log4j.{Level, Logger}
import org.apache.spark.{SparkConf, SparkContext}
object WorldCount {
def main(args: Array[String]): Unit ={
Logger.getLogger("org").setLevel(Level.ERROR)
val conf = new SparkConf().setAppName("wordcount").setMaster("local[2]")
val sc = new SparkContext(conf)
val input = sc.textFile("1.txt")
val result = input.flatMap(_.split(" "))
.map((_, 1))
.reduceByKey(_ + _)
result.foreach(println)
}
}
文件1.txt内容如下:
运行结果:
标签:error log4 contex obj 代码 file master atm nbsp
原文地址:https://www.cnblogs.com/wddqy/p/11969807.html