Created
April 23, 2019 08:28
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
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