请给出一个Scala RDD的HelloWorld例子

package com import org.apache.spark.rdd.RDD import org.apache.spark.SparkConf import org.apache.spark.SparkContext object TestRDD { def main(args: Array[String]): Unit = { val conf = new SparkConf().setAppName("TestRDD").setMaster("local") val sc = new SparkContext(conf) val rdd1 = sc.makeRDD(List(1, 4, 3, 7, 5)) val rdd1_1 = rdd1.map { y => y * y } val aList = rdd1_1.collect() println("map 用法 is " + aList.mkString(",")) val rdd2 = sc.makeRDD(Array(1, 4, 3, 7, 5)) val rdd2_1 = rdd2.filter { x => x < 5 } println("filter 用法 " + rdd2_1.collect().mkString(","))

更多请见:https://blog.csdn.net/qq_44596980/article/details/93309621

原文链接:https://blog.csdn.net/qq_44596980/article/details/93309621

编辑于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券