liveBook · Manning

Name-value pair

As explained in Grokking Concurrency

A key-value pair is a data representation consisting of a key associated with a corresponding value.

A name-value pair associates a key with a corresponding value. In distributed word counting, each word becomes a key and the value 1 records one occurrence. section 13.9

Counting repeated words

A map task might produce [("the", 1), ("take", 1), ("the", 1)]. The reduce task groups the pairs by key and combines the values, producing [("the", 2)]. section 13.10

Name-value pairs support the two phases of the computation:

  • Map tasks read text files, split them into words, and emit key-value pairs. section 13.10
  • Reduce tasks collect values for each unique key and aggregate them into totals. section 13.10

How Grokking Concurrency covers it

How deep it goes
Defines keys and values, demonstrates aggregation, and stops short of broader data-structure implementation details.
Examples
Uses word-count outputs such as ("the", 1), repeated keys, and the aggregated result ("the", 2).
What it assumes
Assumes basic words and dictionaries while introducing map, reduce, keys, values, and aggregation through word counting.
What you can do after
Build it from scratch by emitting word-count pairs and aggregating values for each unique word.
How it connects
Connects name-value pairs with map phase, reduce phase, word count, distributed computing, and aggregation.

Also explained in

Compare how 11 books explain name-value pair →

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.