-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyFunctions.scala
30 lines (21 loc) · 906 Bytes
/
MyFunctions.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
object MyFunctions
{
def main(args: Array[String])
{
val conf = new SparkConf().setMaster("local").setAppName("Scala word count")
val sc = new SparkContext(conf)
/******************************************************/
/* map example */
/******************************************************/
val inputNumbers = sc.parallelize(List(10,20,30,40,50))
val result = inputNumbers.map(x => x * x)
val inputStrings = sc.parallelize(List("a","b","c","d"))
println("Here comes treble => ")
println(inputStrings.collect().mkString(","))
println(inputNumbers.collect().mkString(","))
println(result.collect().mkString("=="))
}
}