Using Hadoop, are my reducers guaranteed to get all the records with the same key?
Question
I'm running a Hadoop job using Hive actually that is supposed to uniq
lines in many text files. In the reduce step, it chooses the most recently timestamped record for each key.
Does Hadoop guarantee that every record with the same key, output by the map step, will go to a single reducer, even if many reducers are running across a cluster?
I worry that the mapper output might be split after the shuffle happens in the middle of a set of records with the same key.
Solution
All values for a key are sent to the same reducer. See this Yahoo! tutorial for more discussion.
This behavior is determined by the partitioner, and might not be true if you use a partitioner other than the default.
OTHER TIPS
Actually, no! You could create a Partitioner
that sent the same key to a different reducer each time the getPartition
is called. It's just not generally a good idea for most applications.
Yes, Hadoop does guarantee that all keys that are the same will go to the same Reducer. This is achieved using a Partition function which buckets the keys using a hash function.
For more information on the Partitioning process take a look at this: Partitioning Data
It specifically talks about how different mappers that process the same key ensure that all keys of a given value end up in the same partition, and thus are processed by the same reducer.