Map Reduce and Hadoop

Example: Count Word Occurrences

/input_key: document name
//input_value: document contents
map(String input_key, String input_value):
  for each word w in input_value:
    EmitIntermediate(w,"1");

//output_key: a word
//output_values: al list of counts
reduce(String output_key, Iterator intermediate_values):
  in result = 0;
  for each v in intermediate_values:
    result+= ParseInt(v)
  Emit(AsString(result))

José M. Vidal .

20 of 24