1).The canonical example application of MapReduce is a process to count
the appearances of
each different word in a set of documents: void
map(String name, String document): // name: document name //
document: document contents for each word w in document:
EmitIntermediate(w, 1);
void reduce(String word, Iterator
partialCounts): // key: a word // values: a list of aggregated
partial counts int result = 0; for each v in partialCounts:
result += ParseInt(v); Emit(result); Here, each document is split in
words, and each word is counted initially with a "1" value by
the Map
function, using the word as the result key. The framework puts together all the
pairs
with the same key and feeds them to the same call to Reduce, thus
this function just needs to
sum all of its input values to find the
total appearances of that word.