liveBook · Manning

MapReduce

As explained in Grokking Concurrency

The map/reduce pattern applies computation independently to partitioned inputs and then combines the intermediate results.

Imagine dividing a mountain of mail among many helpers, letting each helper process a pile, and then combining their results. MapReduce follows this pattern: map applies one operation independently to partitioned inputs, while reduce aggregates the intermediate results. section 7.8 section 13.10

A MapReduce computation usually proceeds in two phases:

  • Map divides input data into chunks and transforms each chunk into intermediate key-value pairs. section 7.8 section 13.10
  • Reduce groups values belonging to each unique key and combines them, producing a consolidated result. section 7.8 section 13.10
  • Multiple processing resources can perform the map work in parallel, and multiple reduce tasks can divide the keys among themselves. section 7.8 section 13.10

Counting words

For text files, map splits the input into words and emits pairs such as ("the", 1), ("take", 1), and ("the", 1). Reduce groups the pairs by key and combines the values, producing ("the", 2). section 13.10

MapReduce resembles fork/join, but its map and reduce stages are more independent and can scale beyond one computer. Frameworks can distribute work across hundreds or thousands of machines, while developers provide the mapping and reduction logic. Spark follows a related model and can cache results across jobs instead of writing each job's data to disk. section 7.8

Visualizes map producing intermediate results before reduce combines them. section 7.8

How Grokking Concurrency covers it

How deep it goes
Explains phases, key-value intermediates, partitioning, scaling, and framework roles without descending into runtime implementation details.
Examples
Uses word-frequency counting, key-value pairs, vote summation, and minimum-value aggregation as concrete examples.
What it assumes
Assumes basic concurrent-programming and task-decomposition concepts while introducing map/reduce as a data-decomposition pattern.
What you can do after
Apply the pattern by partitioning input, emitting key-value pairs, and aggregating values by key.
How it connects
Connects map/reduce with data decomposition, map, fork/join, partitioning, horizontal scaling, Hadoop, and Spark.

Also explained in

Compare how 6 books explain MapReduce →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Concurrency. The section links point to the parts of the book it draws on.