views:

194

answers:

3

I'm running a hadoop job (using hive actually) which is supposed to uniq lines in a lot of text file. More specifically it chooses the most recently timestamped record for each key in the reduce step.

Does hadoop guarantee that every record with the same key, output by the map step, will go to a single reducer, even if there are many reducers running across a cluster?

I'm worried that the mapper output might be split after the shuffle happens, in the middle of a set of records with the same key.

+1  A: 

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.

Karl Anderson
+2  A: 

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.

Binary Nerd
+1  A: 

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.

Bkkbrad