Class WordCountMapper

java.lang.Object
mapreduce.apps.wordcount.studio.WordCountMapper
All Implemented Interfaces:
Mapper<TextSection,​String,​Integer>

public class WordCountMapper extends Object implements Mapper<TextSection,​String,​Integer>
An implementation of the Mapper interface that maps TextSection objects to key-value pairs, where the keys are words and the values are counts. This is used as the mapper for word count.
Author:
__STUDENT_NAME__, Finn Voichick, Dennis Cosgrove (http://www.cse.wustl.edu/~cosgroved/)
  • Constructor Details

    • WordCountMapper

      public WordCountMapper()
  • Method Details

    • map

      public void map​(TextSection textSection, BiConsumer<String,​Integer> keyValuePairConsumer)
      Given a section of text, should find the words in the section and write key value pairs to the given BiConsumer. You should only write words that are of positive length. Also, this mapper should be case-insensitive, meaning that all words should be converted to lower case. You shouldn't do any reducing in this phase, meaning that the values of all of the key-value pairs will be one. It might make sense for this method to return a Collection of key-value pairs, but this is not the case. This method is more general than that. Instead of returning the key-value pairs, you should be writing them to the BiConsumer.
      Specified by:
      map in interface Mapper<TextSection,​String,​Integer>
      Parameters:
      textSection - a section of text
      keyValuePairConsumer - the context used to write the key value pairs
      See Also:
      String.toLowerCase()