spark

计算圆周率

# bin/spark-submit --class org.apache.spark.examples.SparkPi --executor-memory 1G --total-executor-cores 2 ./examples/jars/spark-examples_2.11-2.3.3.jar 100  

wordcount

sc.textFile("input").flatMap(_.split(" ")).map((_,1)).reduceByKey(_+_).collect  

输出

res3: Array[(String, Int)] = Array((scala,2), ("",1), (object,1), (is,1), (python,3), (hello,4), (java,3), (go,1), (and,1))