Last active
August 29, 2015 14:09
-
-
Save bryanyang0528/234cb6a638da2db213ad to your computer and use it in GitHub Desktop.
RDD Sample
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
val num = 1 to 100 | |
//num: scala.collection.immutable.Range.Inclusive = Range(1,2,3,...,100) | |
val numRDD = sc.parallelize(num) | |
//numRDD: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[11] at parallelize at <console>:14 | |
val numFileter = numRDD.filter(_ < 10) | |
//numFileter: org.apache.spark.rdd.RDD[Int] = FilteredRDD[12] at filter at <console>:16 | |
val numMap = numFileter.map(_ + 10) | |
//numMap: org.apache.spark.rdd.RDD[Int] = MappedRDD[13] at map at <console>:18 | |
val numSum = numMap.reduce(_ + _) | |
//numSum: Int = 135 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment