WordCount的实例
来源:互联网 发布:网络游戏破解软件大全 编辑:程序博客网 时间:2024/06/02 00:53
scala> sc.textFile("hdfs://hadoop1:9000/sparktest/hello.txt").flatMap( line => line.split("\t")).collectres8: Array[String] = Array(you, jump, i, jump)scala> sc.textFile("hdfs://hadoop1:9000/sparktest/hello.txt").flatMap( line => line.split("\t")).map( word => (word,1)).collectres9: Array[(String, Int)] = Array((you,1), (jump,1), (i,1), (jump,1))scala> sc.textFile("hdfs://hadoop1:9000/sparktest/hello.txt").flatMap( line => line.split("\t")).map( word => (word,1)).reduceByKey( (x:Int,y:Int) => x + y).collectres10: Array[(String, Int)] = Array((jump,2), (you,1), (i,1))scala> sc.textFile("hdfs://hadoop1:9000/sparktest/hello.txt").flatMap( line => line.split("\t")).map( word => (word,1)).reduceByKey( (_+_)).collectres11: Array[(String, Int)] = Array((jump,2), (you,1), (i,1))scala> sc.textFile("hdfs://hadoop1:9000/sparktest/hello.txt").flatMap( _.split("\t")).map( (_,1)).reduceByKey( (_+_)).collectres12: Array[(String, Int)] = Array((jump,2), (you,1), (i,1))
阅读全文
0 0
- WordCount的实例
- WordCount 实例
- Wordcount实例
- 关于运行hadoop的wordcount实例
- 基于hadoop0.20.2的wordcount实例
- Rhadoop的第一个实例wordcount
- hadoop分布式的启动和wordcount实例
- 使用python实现MapReduce的wordcount实例
- hadoop wordcount运行实例
- WordCount 实例分析
- hadoop-运行WordCount实例
- storm wordcount实例
- Hadoop 运行wordcount 实例
- Hadoop-实例WordCount
- MR代码实例-wordcount
- hadoop wordcount 实例
- spark wordcount 实例
- Mapreduce WordCount实例
- 解决org.xml.sax.SAXParseException:Content is not allowed in prolog
- redis(1)
- FastJSON、Gson和Jackson性能对比和共同缺点,注意事项
- 如何用js得到当前页面的url信息方法(JS获取当前网址信息)
- Elasticsearch(八)elasticsearch数据输入和输出
- WordCount的实例
- 使用idea2017搭建SSM框架
- 删除表或者数据
- 解决 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
- 排序算法总结
- [基础题]1.快速找出一个数组中的最大数、第二大数。
- 【转】丰田栽了的原因,嵌入式软件工程师都该看看
- 蓝桥杯---基础训练---分解质因数(Java)(自写)
- git 服务端搭建记录