Map Sort Reduce
MapReduce extends the Lisp map and reduce in one significant respect: the map function produces not just one result, but a set of results, each of which has a key string. Results are grouped by key.
When our function testforz found a z, it would output (1). But now, we will always produce a key as well, e.g. (z (1)). In Java, to ``emit'' a result, we would say:
mr.collectbecause the intermediate values are always strings.
There is an intermediate Sort process that groups the results for each key. Then reduce is applied to the results for each key, returning the key with the reduced answer for that key.
At the end of the map and sort, we have:
("z" (("1") ("1") ("1")) )with the key and a list of results for that key.