MapReduce案例-wordcount-Reduce阶段代码
生活随笔
收集整理的這篇文章主要介紹了
MapReduce案例-wordcount-Reduce阶段代码
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
public class WordCountReducer extendsReducer<Text,LongWritable,Text,LongWritable> {/*** 自定義我們的reduce邏輯* 所有的key都是我們的單詞,所有的values都是我們單詞出現(xiàn)的次數(shù)* @param key* @param values* @param context* @throws IOException* @throws InterruptedException*/@Overrideprotected void reduce(Text key, Iterable<LongWritable> values,Context context) throws IOException, InterruptedException {long count = 0;for (LongWritable value : values) {count += value.get();}context.write(key,new LongWritable(count));}}
?
總結(jié)
以上是生活随笔為你收集整理的MapReduce案例-wordcount-Reduce阶段代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MapReduce案例-wordcoun
- 下一篇: MapReduce案例-wordcoun