Created
February 22, 2018 05:30
-
-
Save bhawna94/fc3e8b6c3c9ee84d6b2a94bc7ea7c983 to your computer and use it in GitHub Desktop.
spark assignment
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
scala> val line = "hello World" | |
line: String = hello World | |
scala> val list = List(line) | |
list: List[String] = List(hello World) | |
scala> val rdd = sc.parallelize(list) | |
rdd: org.apache.spark.rdd.RDD[String] = ParallelCollectionRDD[0] at parallelize at <console>:28 | |
scala> rdd.collect | |
res0: Array[String] = Array(hello World) |
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
scala> val rdd1 = sc.parallelize(List(1,1,2,3,4,4).distinct) | |
rdd1: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[5] at parallelize at <console>:24 | |
scala> val rdd2 = sc.parallelize(List(1,2,3,4)) | |
rdd2: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[6] at parallelize at <console>:24 | |
scala> rdd1.zip(rdd2) | |
res2: org.apache.spark.rdd.RDD[(Int, Int)] = ZippedPartitionsRDD2[7] at zip at <console>:29 | |
scala> res2.collect | |
res3: Array[(Int, Int)] = Array((1,1), (2,2), (3,3), (4,4)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment