DEV Community

Discussion on: Explain MapReduce like I'm five

Collapse
 
mellen profile image
Matt Ellen • Edited

Map is doing something to a collection of things, which changes each thing in the collection.

So if you had 50 TVs and you want to turn them all off at once, you could use 50 different remote controls one at a time, or you could have a single remote that works on all the TVs at once.

The single remote is like map.

Or if you had a list of things to buy and your friend saw the list and asked you to buy all the same things for them, you could write x2 next to each thing on the list or you could write "buy two of each" at the top.

Writing "buy two of each" is like map.

Like map, reduce is doing something to a collection of things, but instead of ending up with a changed collection, you end up with a single thing.

So if you have a 100 piece jigsaw puzzle, you pick up each piece look at the picture on the box and put the piece on the table in the right place, you go from having 100 separate pieces to having a single picture.

Or if you spill a plate of crumbs on the floor and you want to clean them up you take a vacuum cleaner and suck them up.

MapReduce is mapping a collection, then reducing it.

So, if you wanted to know your favourite flavour of ice cream, you would take a taste from each one (map) and write down the one you liked best (reduce).