Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tangzhankun/02ce6b9e2e2edfb12b712383f6997715 to your computer and use it in GitHub Desktop.
Save tangzhankun/02ce6b9e2e2edfb12b712383f6997715 to your computer and use it in GitHub Desktop.
object SimpleApp {
def main(args: Array[String]) {
val logFile = "userdata.txt" // Should be some file on your system
val spark = SparkSession.builder.appName("Simple Application").getOrCreate()
val sc = spark.sparkContext
val data = Array(1)
val distData = sc.parallelize(data)
distData.map(x => readLocalFile(x)).collect().foreach(println)
spark.stop()
}
def readLocalFile(x: Int) : String = {
val filename = "userdata.txt"
return Source.fromFile(filename).mkString
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment