实例1
var text = sc.parallelize(Seq("a","b","c","a","b","b"))
text.filter(_.contains("a")).count
var wc = text.flatMap(line=>line.split("")).map(word=>(word,1)).reduceByKey((a,b)=>a+b)
wc.collect
val text = sc.textFile("/data/sofoware/unpacks/spark-1.6.2-bin-hadoop2.6/README.md")
text.filter(line=>line.contains("Apache Spark")).count
网友评论