# Why does the map function in MapReduce take two parameters?

I am playing around with MapReduce and wanted to ask why the map function takes two inputs (key, value)? Why not just pass along the value?

Specifically, if you look at the word count example on Wikipedia page you will see that the map function is:

function map(String name, String document):
// name: document name
// document: document contents
for each word w in document:
emit (w, 1)


However, the function never does anything with the parameter "name". Why even pass it in?

• This is almost a pure programming question (which would be offtopic here, but ontopic on Stack Overflow) but it seems to allow some general answers, so I'll leave it here. – Raphael Sep 16 '13 at 7:39

• Use the "chunk" name in the returned names. For example, you might want to distinguish bible_author from fiftyshadesofgrey_author in the result.
• Identify "subprocesses". If anything goes wrong (and something will go wrong) an error message like "Error processing bible: Illegal character at position 666" is obviously only useful if you include the document name.