86

golang实现mapreduce单进程版本

 6 years ago
source link: http://vinllen.com/golangshi-xian-mapreducedan-jin-cheng-ban-ben/?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
  元旦放假的第一天,在家没事干,用golang实现了一下mapreduce的单进程版本,github地址。处理对大文件统计最高频的10个单词,因为功能比较简单,所以设计没有解耦合。   本文先对mapreduce大体概念进行介绍,然后结合代码介绍一下,如果接下来几天有空,我会实现一下分布式高可用的mapreduce版本。 1. Mapreduce大体架构   上图是论文中mapreduce的大体架构。总的来说Mapreduce的思想就是分治思想:对数据进行分片,然后用mapper进行处理,以key-value形式输出中间文件;然后用reducer进行对mapper输出的中间文件进行合并:将key一致的合到一块,并输出结果文件;如果有需要,采用Combiner进行最后的合并。   归纳来说主要分为5部分:用户程序、Master、Mapper、Reducer、Combiner(上图未给出)。 用户程序。用户程序主要对输入数据进行分割,制定Mapper、Reducer、Combiner的代码。 Master:中控系统。控制分发Mapper、Reduer的个数,比如生成m个进程处理Mapper,n个进程处理Reducer。其实对Master来说,

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK