object ScalaApp { def main(args: Array[String]): Unit = { var conf = new SparkConf() conf.setMaster("local") var sc = new SparkContext(conf) val lines: RDD[String] = sc.textFile("./words.txt") lines.flatMap(line=>line.split()).reduc…
[学习笔记] reduce将RDD中元素前两个传给输入函数,产生一个新的return值,将新产生的return值与RDD中下一个元素(即第三个元素)组成两个元素,再被传给输入函数,这样递归运作,直到最后只有一个值为止.*/ val rdd07 = sc.parallelize(1 to 10) val sum = rdd07.reduce((x, y) => x + y) println("sum is " + sum) 文章转载自原文:https://blog…
scala集合转化为DS/DF case class TestPerson(name: String, age: Long, salary: Double) val tom = TestPerson(,35.5) val sam = TestPerson(,40.5) val PersonList = mutable.MutableList[TestPerson]() PersonList += tom PersonList += sam val personDS = PersonList.to…
NetworkWordCount.scala /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF lice…