1、读取文件当中每一行的数据 def main(args: Array[String]): Unit = { //注意文件的编码格式,如果编码格式不对,那么读取报错 val file: BufferedSource = Source.fromFile("F:\\files\\file.txt","G... ...
分类:
其他好文 时间:
2019-03-03 20:19:35
阅读次数:
181
1、作为参数的函数 函数可以作为一个参数传入到一个方法当中去 def main(args: Array[String]): Unit = { val myFunc1 =(x:Int) =>{ x * x } val myArray = Array(1,3,5,7,9).map(myFunc1) pr... ...
分类:
其他好文 时间:
2019-03-03 17:41:04
阅读次数:
158
版本HttpCilent 4.5.3 1.GET请求 2.GET请求,设置 超时时间 3.POST请求,参数 4.Post 请求,map参数 5.POST 请求,参数是json字符串 ...
分类:
Web程序 时间:
2019-02-22 00:38:37
阅读次数:
330
package com.bigdata object ListO { def main(args: Array[String]): Unit = { println() } val list = List(1,2,3,4) for (i x%2 == 0) // 取出List中的偶数; val li... ...
分类:
其他好文 时间:
2019-02-14 15:14:06
阅读次数:
140
package com.bigdata object TupleMapO { def main(args: Array[String]): Unit = { // 元组:Tuple,就是由()包起来,和数据库中一条记录概念类似 val t2 = (1,"xiaoming","男",23,"高新区")... ...
分类:
其他好文 时间:
2019-02-14 15:04:24
阅读次数:
232
Spark中文分词一、导入需要的分词包importorg.ansj.domain.Termimportorg.ansj.recognition.impl.StopRecognitionimportorg.ansj.splitWord.analysis.ToAnalysis二、停用词过滤deffilter(stopWords:Array[String]):StopRecognition={//add
分类:
其他好文 时间:
2019-02-12 18:47:20
阅读次数:
254
object Test { def main(args: Array[String]): Unit = { val a1 = new tt //实例化对象 println(a1.a) a1.f(2) println(a1.a) println(a1) } } //定义一个类叫tt class tt{... ...
分类:
其他好文 时间:
2019-01-27 16:34:54
阅读次数:
152
object ScalaApp { def main(args: Array[String]): Unit = { var conf = new SparkConf() conf.setMaster("local") var sc = new SparkContext(conf) val lines... ...
分类:
其他好文 时间:
2019-01-20 15:03:57
阅读次数:
471
/** * @param array JSON数组 * @param array 需合并后的某个元素名 */ private static JSONArray mgreArray(JSONArray array, String arrayname) { Map map = new HashMap()... ...
分类:
编程语言 时间:
2019-01-11 15:55:14
阅读次数:
287
(1)StreamingContext 与sparkcore的编程类似,在编写SparkStreaming的程序时,也需要一个通用的编程入口----StreamingContext。StreamingContext的创建:objectStreamingContextTest{defmain(args:Array[String]):Unit={valsparkConf=newS
分类:
其他好文 时间:
2019-01-07 00:09:39
阅读次数:
233