Difference between revisions of "Windbag MapReduce Application"
AngelaChen (talk | contribs) |
|||
| Line 3: | Line 3: | ||
=Background= | =Background= | ||
| − | A windbag is [https://www.merriam-webster.com/dictionary/windbag an exhaustively talkative person]. | + | A windbag is [https://www.merriam-webster.com/dictionary/windbag an exhaustively talkative person]. [http://shakespeare.mit.edu/hamlet/hamlet.1.3.html Act I Scene 3 of Hamlet] has a [https://en.wikipedia.org/wiki/Polonius#Famous_lines famous example]. |
| − | [ | + | In this assignment we will try to determine who is the biggest windbag in a particular play with [https://en.wikipedia.org/wiki/Hamlet Hamlet] and [https://en.wikipedia.org/wiki/The_Importance_of_Being_Earnest The Importance of Being Earnest] serving as two pieces of data. |
=Code To Implement= | =Code To Implement= | ||
Revision as of 18:39, 7 March 2023
Contents
Motivation
A simple Mapper and two simple Collectors reinforce our understanding of how pieces of the MapReduce puzzle can be reused. Further, we will reduce the value type of Boolean to both an Integer and a Double in two different Collectors.
Background
A windbag is an exhaustively talkative person. Act I Scene 3 of Hamlet has a famous example.
In this assignment we will try to determine who is the biggest windbag in a particular play with Hamlet and The Importance of Being Earnest serving as two pieces of data.
Code To Implement
WindbagMapper
| class: | WindbagMapper.java | |
| methods: | map | |
| package: | mapreduce.apps.windbag.studio | |
| source folder: | student/src/main/java |
Note: the WindBagMapper is constructed with an IntPredicate. This IntPredicate's test method should be invoked to determine if a PlayLine's word count qualifies it as a windbag line. You can investigate the PlayLine class to see what information it contains.
method: public void map(PlayLine item, BiConsumer<PlayRole, Boolean> keyValuePairConsumer)
(sequential implementation only)
TrueCountClassicReducer
This Collector reduces to the number of emitted trues.
For example, if a total of eight (8) values were emitted for a particular key and three (3) of them were true:
[false, true, false, false, true, true, false, false]
then the reduced value would be 3
| class: | TrueCountClassicReducer.java | |
| methods: | reduce | |
| package: | mapreduce.apps.windbag.exercise | |
| source folder: | student/src/main/java |
method: public Integer reduce(List<Boolean> container)
(sequential implementation only)
TruePortionClassicReducer
This Collector reduces to the portion of emitted trues.
For example, if a total of eight (8) values were emitted for a particular key and three (3) of them were true:
[false, true, false, false, true, true, false, false]
then the reduced value would be 0.375
| class: | TruePortionClassicReducer.java | |
| methods: | reduce | |
| package: | mapreduce.apps.windbag.exercise | |
| source folder: | student/src/main/java |
method: public Double reduce(List<Boolean> container)
(sequential implementation only)
Testing Your Solution
Correctness
| class: | WindbagStudioTestSuite.java | |
| package: | mapreduce | |
| source folder: | testing/src/test/java |
Output
| class: | WindbagApp.java | |
| package: | mapreduce.apps.windbag.client | |
| source folder: | src/main/java |
COUNT
===========================
HAMLET: 27
KING: 14
POLONIUS: 7
HORATIO: 5
OPHELIA: 2
GHOST: 2
FIRST PLAYER: 2
LAERTES: 1
ROSENCRANTZ: 1
VOLTEMAND: 1
PLAYER KING: 1
GENTLEMAN: 1
PLAYER QUEEN: 1
QUEEN: 1
PORTION
===========================
VOLTEMAND: 1.000000
GENTLEMAN: 0.333333
PLAYER KING: 0.250000
FIRST PLAYER: 0.250000
PLAYER QUEEN: 0.200000
GHOST: 0.142857
KING: 0.137255
POLONIUS: 0.081395
HAMLET: 0.075419
HORATIO: 0.046729
OPHELIA: 0.034483
ROSENCRANTZ: 0.022222
LAERTES: 0.016129
QUEEN: 0.014493