Created
October 26, 2015 01:23
-
-
Save toff63/0a583f94ff1f0a06c2c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.SparkContext | |
import org.apache.spark.SparkContext._ | |
import org.apache.spark.SparkConf | |
object SimpleApp { | |
def main(args:Array[String]) { | |
val logFile = "/mnt/home2/Documents/bin/spark-1.5.1-bin-hadoop2.6/README.md" | |
val conf = new SparkConf().setAppName("Simple App") | |
val sparkContext = new SparkContext(conf) | |
val logData = sparkContext.textFile(logFile,2).cache() | |
val numberOfAs = logData.filter(line => line.contains("a")).count | |
val numberOfBs = logData.filter(line => line.contains("b")).count | |
println(s"Lines with a: $numberOfAs , Lines with b: $numberOfBs ") | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment