TakeOperator

package com.bjsxt.study.scala.operator

import org.apache.spark.{SparkContext, SparkConf}

/**
  * Created by root on 2016/6/13.
  */
object TakeOperator {

  def main(args: Array[String]) {
    val conf = new SparkConf().setAppName("CollectOperator")
      .setMaster("local")
    val sc = new SparkContext(conf)
    val numberArray = Array(1,2,3,4,5)
    val numbers = sc.parallelize(numberArray)
    val numbersTop3 = numbers.take(3)
    for(num <- numbersTop3){
      println(num)
    }
  }
}

  

posted @ 2018-06-18 14:59  uuhh  阅读(86)  评论(0)    收藏  举报