作用:返回一个由RDD的前n个元素组成的数组
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.take(2)
array.foreach(println)
}
}
1
4
网友评论