作用:在驱动程序中,以数组的形式返回数据集的所有元素。
将结果收集到Driver端。
package com.atguigu
import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}
object Action {
def main(args: Array[String]): Unit = {
val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("ADCount")
val sc = new SparkContext(conf)
val rdd: RDD[Int] = sc.makeRDD(List(1,4,3,2))
val array: Array[Int] = rdd.collect()
array.foreach(println)
}
}
1
4
3
2
网友评论