MapReduce Pseudocode Consider the following pseudo code for mapreduce to find the frequency of words in a collection of documents:

map(String key, String value)
// key: document name
// value: document contents
 for each word w in value
   EmitIntermediate(w, "1")

reduce(String key, Iterator values):
// key: word
// values: a list of counts
  for each v in values:
    result += ParseInt(v);
    Emit(AsString(result));


So the map step gets each word as a key and output its frequency in a document. Does the reduce step sum the counts of each word?
MapReduce groups everything by key, in this case the word. So the reducer gets the word, followed by a list of 1's. The length of that list is the number of times this word occurs in the text. The reducers sums up the ones to count the word.