a**********0 发帖数: 422 | 1 在我自己写map reduce的时候有时候写combiner 但是很少有机会写partiioner
具体用的顺序如何 map -> combiner -> partioner -> reducer
也就是说 combiner必须在partioner之前呢 | J****3 发帖数: 427 | 2 个人理解 partitioner 是将前面处理完的K-V pairs 按你的P 函数 决定这些数据所去
向的reducer。 combiner 是提前先处理map 出的结果 减少reduce part的负担, 大部
分combine的函数和reduce的函数也基本一致。 | j*******t 发帖数: 223 | 3 大体顺序是这样的。有一点需要注意的是combiner的输出格式需要和map保证一样。即
不光是数据类型一样(这个编译器基本可以保证),含义也应该一样。
k1,v1 -> map -> k2,v2
k2,v2 -> combiner -> k2,v2
k2,v2 -> reduce -> k3,v3
需要注意的一点是combiner的行为在不同的版本不一样,具体可以参考HADOOP-3586,
https://issues.apache.org/jira/browse/HADOOP-3586。
基本大意就是:combiner可能会运行0-N次,因此一个程序应该考虑到无论combiner调
用多少次,其结果都应该正确。 | u*****o 发帖数: 1224 | 4 我想问问partitioner的作用是什么呢?
比如那个word count的例子
mapper input(line, text) --> output(word, frequency)
combiner input(word, frequency) --> output(word frequency)
combines results from multiple mappers..
Then we use reducer to sort words according to index (e.g. 26 reducers and
each take words for a particular alphabet).
这个例子中如果fit in partitioner呢?
【在 j*******t 的大作中提到】 : 大体顺序是这样的。有一点需要注意的是combiner的输出格式需要和map保证一样。即 : 不光是数据类型一样(这个编译器基本可以保证),含义也应该一样。 : k1,v1 -> map -> k2,v2 : k2,v2 -> combiner -> k2,v2 : k2,v2 -> reduce -> k3,v3 : 需要注意的一点是combiner的行为在不同的版本不一样,具体可以参考HADOOP-3586, : https://issues.apache.org/jira/browse/HADOOP-3586。 : 基本大意就是:combiner可能会运行0-N次,因此一个程序应该考虑到无论combiner调 : 用多少次,其结果都应该正确。
| J****3 发帖数: 427 | 5 你可以自己实现partitioner based on Alphabets, for example, reducer1 output
words initial from A-F, reducer 2 output initial from G-J ...
【在 u*****o 的大作中提到】 : 我想问问partitioner的作用是什么呢? : 比如那个word count的例子 : mapper input(line, text) --> output(word, frequency) : combiner input(word, frequency) --> output(word frequency) : combines results from multiple mappers.. : Then we use reducer to sort words according to index (e.g. 26 reducers and : each take words for a particular alphabet). : 这个例子中如果fit in partitioner呢?
| j*******t 发帖数: 223 | 6 partitioner的作用就是对map过后的进行划分,用于确定在reduce端哪些kv pair放在
一个reducer里面(即在一个Iterator里面)。
要实现自己的partioner,需要继承Partitioner抽象类,并实现int
getPartition(KEY key, VALUE value, int numPartitions) 方法。hash是一个比较常
见的实现方法,一般情况下只有key会用到。 | a**********0 发帖数: 422 | 7 没有人讲讲如果combiner和partitioner同时使用谁在前谁在后 |
|