ReduceOperator

package com.bjsxt.study.scala.operator

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

/**
  * Created by root on 2016/6/13.
  */
object ReduceOperator {
  def main(args: Array[String]) {
    val conf = new SparkConf().setAppName("ReduceOperator")
      .setMaster("local")
    val sc = new SparkContext(conf)
    val numberArray = Array(1,2,3,4,5)
    val numbers = sc.parallelize(numberArray)
    val sum = numbers.reduce(_+_)
    println(sum)
  }
}

  

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