映射方法:接收作为输入 (K1,V1) 并返回 (K2,V2)。也就是说,输出键和值可以不同于输入键和值。
Reducer 方法:在 mapper 的输出被正确打乱后(相同的 key 进入相同的 reducer),reducer 的输入为 (K2, LIST(V2)),其输出为 (K3,V3)。作为 shuffle 过程的结果,key 到达了由 key K2 排序的 reducer。
如果您想以您的特定方式对键进行排序,您可以实现键 K3 的 compareTo 方法。
Referring your questions:
1. Answered above.
2. You can emit whatever you want as long it consists of a key and a value.
For example, in the WordCount you send as key the word and as value 1.
3. In the WordCount example, the reducer will receive a word and list of number.
Then, it will sum up the numbers and emit the word and its sum.
4. Answered above.
5. Answered above.