Is there a way in Hadoop to ensure that every reducer gets only one key that is output by the mapper ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This question is a bit unclear for me. But I think I have a pretty good idea what you want.
First of all if you do nothing special every time a reduce is called it gets only one single key with a set of one or more values (via an iterator).
My guess is that you want to ensure that every reducer gets exactly one ‘key-value pair’.
There are essentially two ways of doing that:
So if I understand your question correctly. You should implement a GroupComparator that simply states that all keys are different and should therefor be sent to a different reducer call.
Because of other answers in this question I’m adding a bit more detail:
There are 3 methods used for comparing keys (I pulled these code samples from a project I did using the 0.18.3 API):
Partitioner
The partitioner is only to ensure that “things that must be the same end up on the same partition”. If you have 1 computer there is only one partition, so this won’t help much.
Key Comparator
The key comparator is used to SORT the “key-value pairs” in a group by looking at the key … which must be different somehow.
Group Comparator
The group comparator is used to group keys that are different, yet must be sent o the same reducer.
HTH