Word Count (Map Reduce)
来源:互联网 发布:备案域名交易平台top 编辑:程序博客网 时间:2024/06/05 11:26
Using map reduce to count word frequency.
java
/** * Definition of OutputCollector: * class OutputCollector<K, V> { * public void collect(K key, V value); * // Adds a key/value pair to the output buffer * } */public class WordCount { public static class Map { public void map(String key, String value, OutputCollector<String, Integer> output) { // Write your code here // Output the results into output buffer. // Ps. output.collect(String key, int value); StringTokenizer tokenizer = new StringTokenizer(value); while (tokenizer.hasMoreTokens()) { String word = tokenizer.nextToken(); output.collect(word, 1); } } } public static class Reduce { public void reduce(String key, Iterator<Integer> values, OutputCollector<String, Integer> output) { // Write your code here // Output the results into output buffer. // Ps. output.collect(String key, int value); int sum = 0; while (values.hasNext()) { sum += values.next(); } output.collect(key, sum); } }}
阅读全文
0 0
- Word Count (Map Reduce)
- Word Count (Map Reduce)
- 从word count分析Map Reduce / Map Reduce的word count讲解
- Swift 函数Count,Filter,Map,Reduce
- map/reduce
- map reduce
- Map/Reduce
- map reduce
- Map Reduce
- map reduce
- map-reduce
- Map-Reduce
- Map Reduce
- Map Reduce
- Map/Reduce
- map&reduce
- map/reduce
- map/reduce
- 遇到版本号判断的一个原则
- 第一个安卓驱动程序
- Vue中使用vux的配置,分为两种情况:
- Windows Server2008 R2安装Mysql5.7.19时遇到问题:
- Mapreduce实现MapSideJoin
- Word Count (Map Reduce)
- Kotlin 一统天下?Kotlin/Native 开始支持 iOS 和 Web 开发
- Kaldi HMM拓扑和状态转换模型
- VueJs 监听 window.resize 方法---窗口变化
- WAP_WSP的Well-known header
- 优雅的QSignleton (一) Singleton单例实现
- MySQL学习(二)【MySQL数据库对象与应用】
- sigaction-sigqueue
- 解决客户端 query did not return aunique result:2