Package mapreduce.apps.wordcount.studio
Class WordCountMapper
java.lang.Object
mapreduce.apps.wordcount.studio.WordCountMapper
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidmap(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 givenBiConsumer.
-
Constructor Details
-
WordCountMapper
public WordCountMapper()
-
-
Method Details
-
map
Given a section of text, should find the words in the section and write key value pairs to the givenBiConsumer. 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 aCollectionof 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 theBiConsumer.- Specified by:
mapin interfaceMapper<TextSection,String,Integer>- Parameters:
textSection- a section of textkeyValuePairConsumer- the context used to write the key value pairs- See Also:
String.toLowerCase()
-