Created
April 23, 2019 08:28
-
-
Save tangzhankun/02ce6b9e2e2edfb12b712383f6997715 to your computer and use it in GitHub Desktop.
This file contains 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
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