Why is MRJob sorting my keys?

╄→гoц情女王★ 提交于 2019-12-11 01:38:03

问题


I'm running a fairly big MRJob job (1,755,638 keys) and the keys are being written to the reducers in sorted order. This happens even if I specify that Hadoop should use the hash partitioner, with:

class SubClass(MRJob):

    PARTITIONER = "org.apache.hadoop.mapred.lib.HashPartitioner"

...

I don't understand why the keys are sorted, when I am not asking for them to be sorted.


回答1:


The HashPartitioner is used by default when you don't specify any partitioner explicitly.




回答2:


Keys are not sorted by default, but the HashPartitioner will give the appearance of sorting keys if the dataset is small. When I increased the size of the dataset from 50M to 10G the keys stopped being sorted.




回答3:


MR sorts the key/value pairs by key so that it can ensure that all values for a given key are passed to the reducer together. In fact, the Iterable passed into the reduce() method just reads that sorted list until it finds a new key and then it stops iterating. That's why the keys will always appear in order.



来源:https://stackoverflow.com/questions/42078886/why-is-mrjob-sorting-my-keys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!