/** * Created by root on 9/6/15. */ import org.apache.spark.SparkContext import org.apache.spark.SparkConf object HelloSpark { def main(args: Array[String]) { val logFile = "/home/slh/data/README.txt" // Should be some file on your system val conf = new SparkConf().setAppName("Simple Application") val sc = new SparkContext(conf) val logData = sc.textFile(logFile, 2).cache() val numAs = logData.filter(line => line.contains("a")).count() val numBs = logData.filter(line => line.contains("b")).count() println("Lines with a: %s, Lines with b: %s".format(numAs, numBs)) } }
时间: 2024-11-17 02:40:06