请给出一个Scala RDD的HelloWorld例子
程序员文章站
2022-04-15 15:17:32
[学习笔记]package comimport org.apache.spark.rdd.RDDimport org.apache.spark.SparkConfimport org.apache.spark.SparkContextobject TestRDD { def main(args: A ......
[学习笔记]
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(","))
文章转载自原文:
上一篇: pymysql 的简单使用