tag:blogger.com,1999:blog-9063322533488292362023-11-15T05:06:55.053-08:00Map and Reduce using Java Concurrency API'sThis blogs discusses the techniques of using Java Concurrency API's to do map and reduceAnonymoushttp://www.blogger.com/profile/05317963248286212417noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-906332253348829236.post-14215674625441862002012-12-27T14:37:00.003-08:002012-12-29T16:41:19.305-08:00Creating a Simple Map and Reduce with Java Concurrency<br />
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin: 0.4em 0px 0.5em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
Definition</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin: 0.4em 0px 0.5em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
========</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin: 0.4em 0px 0.5em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
MapReduce is a framework for processing <a href="http://en.wikipedia.org/wiki/Parallel_computing" style="background-image: none; background-position: initial initial; background-repeat: initial initial; color: #0b0080; text-decoration: initial;" title="Parallel computing">parallelizable</a> problems across huge datasets using a large number of computers (nodes). Computational processing can occur on data stored either in a <a class="mw-redirect" href="http://en.wikipedia.org/wiki/Filesystem" style="background-image: none; background-position: initial initial; background-repeat: initial initial; color: #0b0080; text-decoration: initial;" title="Filesystem">filesystem</a> (unstructured) or in a <a href="http://en.wikipedia.org/wiki/Database" style="background-image: none; background-position: initial initial; background-repeat: initial initial; color: #0b0080; text-decoration: initial;" title="Database">database</a> (structured). MapReduce can take advantage of locality of data, processing data on or near the storage assets to decrease transmission of data.</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin: 0.4em 0px 0.5em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<b>"Map" step:</b> The master node takes the input, divides it into smaller sub-problems, and distributes them to worker nodes. A worker node may do this again in turn, leading to a multi-level <a href="http://en.wikipedia.org/wiki/Tree_(data_structure)" style="background-image: none; background-position: initial initial; background-repeat: initial initial; color: #0b0080; text-decoration: initial;" title="Tree (data structure)">tree</a> structure. The worker node processes the smaller problem, and passes the answer back to its master node.</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin: 0.4em 0px 0.5em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<b>"Reduce" step:</b> The master node then collects the answers to all the sub-problems and combines them in some way to form the output – the answer to the problem it was originally trying to solve.</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin: 0.4em 0px 0.5em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin: 0.4em 0px 0.5em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
Reference:<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><a href="http://en.wikipedia.org/wiki/MapReduce">http://en.wikipedia.org/wiki/MapReduce</a></span></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin: 0.4em 0px 0.5em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<b><u>Map and Reduce using Hadoop(Word Count Example)</u></b></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin: 0.4em 0px 0.5em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
As most of you know the most famous Word count example where the mappers read different portion of the document and basically maps all the input words with occurrence and finally the reducer merges all the result to one and basically outputs the word count of the entire document.If you need more details you can look at this link <span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><a href="http://hadoop.apache.org/docs/r0.20.2/mapred_tutorial.html#Example%3A+WordCount+v1.0">http://hadoop.apache.org/docs/r0.20.2/mapred_tutorial.html#Example%3A+WordCount+v1.0</a></span></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin: 0.4em 0px 0.5em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<b><u>Using JAVA concurrency api to perform Map and Reduce</u></b></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; letter-spacing: normal; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<span class="Apple-style-span" style="line-height: 19.200000762939453px;">Java introduced the concurrency package (java.util.concurrent ) as part of JDK 5.0 and it was a major step towards build high-performance parallel executing processes.If you need more details about the API you can visit the blog written by Brian Goetz</span> <span class="Apple-style-span" style="line-height: 19.200000762939453px;"> </span><span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><a href="http://www.ibm.com/developerworks/java/tutorials/j-concur/">http://www.ibm.com/developerworks/java/tutorials/j-concur/</a>.</span></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; letter-spacing: normal; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;">In this blog I am going to show how we can achieve Map and Reduce using Java Concurrency API's.</span><span class="Apple-style-span" style="font-family: Times; font-size: small;">We are going to implement the classic Word Count Example.We are going to read a sample document and then create a list of all the input lines of the document and then we are going to process this list in parallel using </span><span class="Apple-style-span" style="font-family: Times; font-size: small;"><u><i><b>multiple threads -Callable Tasks</b></i></u></span><span class="Apple-style-span" style="font-family: Times; font-size: small;"> .</span></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-variant: normal; letter-spacing: normal; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<div style="font-family: sans-serif; font-size: 13px;">
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><br /></span></div>
<div style="font-family: sans-serif; font-size: 13px;">
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;">Each Callable Task is going to take as an input a sublist from this main document list and then process the entries tokenize them and then perform a basic mapping of the words along with the counts .Each Callable Task produces a map of the words with counts and the result comes back as an output map and finally there is a reducer process that basically combines all these intermediate maps and aggregates the counts and produces a final map with all the word counts.</span></div>
</div>
<div style="background-color: white; margin: 0.4em 0px 0.5em; orphans: 2; text-align: start; text-indent: 0px; widows: 2;">
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px;">
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;">The full code is available on GitHub at the following location</span></div>
<span class="Apple-style-span" style="font-family: Times; font-size: small;"><br /></span>
<span class="Apple-style-span" style="font-family: Times; font-size: small;"><a href="https://github.com/raghuramgururajan/JavaMapAndReduce/">https://github.com/raghuramgururajan/JavaMapAndReduce/</a></span><br />
<span class="Apple-style-span" style="font-family: Times; font-size: small;"><br /></span>
<span class="Apple-style-span" style="font-family: Times; font-size: small;"><br /></span></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-style: normal; font-variant: normal; letter-spacing: normal; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<span class="Apple-style-span" style="font-family: Times; line-height: normal;"><b>Step1:Define the class that is basically going to process the input</b></span></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; letter-spacing: normal; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><b><u>WordCountProcessor.java</u></b></span></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-style: normal; font-variant: normal; letter-spacing: normal; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<b></b><br />
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<b>/**</b></div>
<b>
</b>
<br />
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<b> * This class is basically used to read the sample file and then configure the thread pools,determine number of threads available and </b></div>
<b>
</b>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<b> * then delegate the work to WordCountMapper and WordCountReducer and display the final output of wordcount</b></div>
<b>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
* <span style="color: #92b0c9;">@author</span> raghuramgururajan</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
*</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
*/</div>
</b></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; letter-spacing: normal; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><b></b></span><br />
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">package</span> com.example.java.concurrency.wordcount;</b></span></div>
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><b>
</b></span>
<br />
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><b><br /></b></span></div>
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><b>
</b></span>
<br />
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">import</span> java.io.BufferedReader;</b></span></div>
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><b>
</b></span>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">import</span> java.io.File;</b></span></div>
<span class="Apple-style-span" style="font-family: Times; font-size: small; line-height: normal;"><b>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.io.FileReader;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.io.IOException;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.net.URISyntaxException;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.util.ArrayList;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.util.Iterator;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.util.List;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.util.Map;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.util.Properties;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.util.concurrent.Callable;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.util.concurrent.Future;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.util.concurrent.LinkedBlockingQueue;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.util.concurrent.ThreadPoolExecutor;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> java.util.concurrent.TimeUnit;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> org.apache.commons.io.IOUtils;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">import</span> org.apache.log4j.Logger;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #921f67;">public</span> <span style="color: #921f67;">class</span> WordCountProcessor {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>Properties <span style="color: #0a30c8;">config</span> = <span style="color: #921f67;">null</span>;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">private</span> <span style="color: #921f67;">static</span> Logger <span style="color: #0a30c8;">log</span> = Logger.getLogger(WordCountProcessor.<span style="color: #921f67;">class</span></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>.getName());</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>/**</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * This method basically reads the input file and calls mapper to process</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * the data.There are multiple threads that basically process the input and</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * one reducer that basically finally merges the input</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * </div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * <span style="color: #92b0c9;">@param</span> inputFileName</div>
<div style="color: #92b0c9; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #5178c8;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * </span>@return</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> */</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">public</span> Map<String, Integer> processMapAndReduce(String inputFileName) {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>BufferedReader br = <span style="color: #921f67;">null</span>;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>FileReader fr = <span style="color: #921f67;">null</span>;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>Map<String, Integer> wordCountMap = <span style="color: #921f67;">null</span>;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">try</span> {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>File inputFile = <span style="color: #921f67;">new</span> File(</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>(<span style="color: #921f67;">this</span>.getClass().getClassLoader()</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>.getResource(inputFileName)).toURI());</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>fr = <span style="color: #921f67;">new</span> FileReader(inputFile);</div>
<div style="color: #508f73; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// URLConnection yc = oracle.openConnection();</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>br = <span style="color: #921f67;">new</span> BufferedReader(fr);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">long</span> contentLength = inputFile.length();</div>
<div style="color: #508f73; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// Number of threads are determined from run time</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">int</span> numberOfThreads = Runtime.getRuntime().availableProcessors();</div>
<div style="color: #508f73; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// Thread pool executor initialized</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>ThreadPoolExecutor threadpoolExecutor = <span style="color: #921f67;">new</span> ThreadPoolExecutor(</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>numberOfThreads, numberOfThreads, 10, TimeUnit.<span style="color: #0a30c8;">SECONDS</span>,</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">new</span> LinkedBlockingQueue<Runnable>());</div>
<div style="color: #508f73; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// Thread pool executor invoked</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>wordCountMap = invokeThreadExecutor(threadpoolExecutor,</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>contentLength, numberOfThreads, br);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} <span style="color: #921f67;">catch</span> (IOException e) {</div>
<div style="color: #3b3ffb; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="color: #0a30c8;">log</span><span style="color: black;">.error(</span>"IOException occured in WordCountProcessor:: processMapAndReduce"</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ e.toString());</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} <span style="color: #921f67;">catch</span> (URISyntaxException e) {</div>
<div style="color: #508f73; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// <span style="color: #92b0c9;">TODO</span> Auto-generated catch block</div>
<div style="color: #3b3ffb; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="color: #0a30c8;">log</span><span style="color: black;">.error(</span>"URISyntaxException occured in WordCountProcessor:: processMapAndReduce"</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ e.toString());</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="color: #921f67; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>finally<span style="color: black;"> {</span></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>IOUtils.closeQuietly(br);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>IOUtils.closeQuietly(fr);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">return</span> wordCountMap;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>/**</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * Method to actually create and invoke multiple threads to process the</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * input word set</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * </div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * <span style="color: #92b0c9;">@param</span> threadpoolExecutor</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * <span style="color: #92b0c9;">@param</span> contentLength</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * <span style="color: #92b0c9;">@param</span> numberOfThreads</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * <span style="color: #92b0c9;">@param</span> in</div>
<div style="color: #92b0c9; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: #5178c8;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * </span>@return</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * <span style="color: #92b0c9;">@throws</span> IOException</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> */</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">private</span> Map<String, Integer> invokeThreadExecutor(</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>ThreadPoolExecutor threadpoolExecutor, <span style="color: #921f67;">long</span> contentLength,</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">int</span> numberOfThreads, BufferedReader br) <span style="color: #921f67;">throws</span> IOException {</div>
<div style="color: #508f73; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// <span style="color: #92b0c9;">TODO</span> Auto-generated method stub</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<Callable<WordCountStatus>> wordCountTasks = <span style="color: #921f67;">new</span> ArrayList<Callable<WordCountStatus>>();</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">int</span> beginOffset = 0;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">int</span> endOffset = 0;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>Map<String, Integer> wordCountMap = <span style="color: #921f67;">null</span>;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<Future<WordCountStatus>> wordCountFutureList = <span style="color: #921f67;">null</span>;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">try</span> {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> inputWordsList = getInputList(br);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">int</span> contentLengthPerThread = getContentLengthPerThread(</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>numberOfThreads, inputWordsList);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>endOffset = contentLengthPerThread;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.<span style="color: #0a30c8;">out</span></div>
<div style="color: #3b3ffb; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span>.println(</span>"::::::::::::::::::::::::::::::::::Calling Mapper to map the words::::::::::::::::::::::::::::::::"<span style="color: black;">);</span></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">for</span> (<span style="color: #921f67;">int</span> i = 0; i < numberOfThreads; i++) {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.<span style="color: #0a30c8;">out</span>.println((((<span style="color: #921f67;">float</span>) (i + 1) / numberOfThreads) * 100)</div>
<div style="color: #3b3ffb; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span>+ </span>"% mapping complete"<span style="color: black;">);</span></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">if</span> (!inputWordsList.isEmpty()) {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> subListInputWords = inputWordsList.subList(</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>beginOffset, endOffset);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>WordCountMapper wcm = <span style="color: #921f67;">new</span> WordCountMapper(subListInputWords);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>wordCountTasks.add(wcm);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>beginOffset = endOffset;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>endOffset = endOffset + contentLengthPerThread;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">if</span> (beginOffset >= contentLength</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>|| beginOffset == endOffset</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>|| endOffset > inputWordsList.size()) {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">break</span>;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">if</span> (endOffset > contentLength) {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>endOffset = (<span style="color: #921f67;">int</span>) contentLength;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>wordCountFutureList = threadpoolExecutor.invokeAll(wordCountTasks);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>WordCountReducer wcr = <span style="color: #921f67;">new</span> WordCountReducer();</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.<span style="color: #0a30c8;">out</span></div>
<div style="color: #3b3ffb; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span>.println(</span>"::::::::::::::::::::::::::::::::Calling reducer to reduce the words::::::::::::::::::::::::::::::::"<span style="color: black;">);</span></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>wordCountMap = wcr.reduce(wordCountFutureList);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>threadpoolExecutor.shutdown();</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} <span style="color: #921f67;">catch</span> (IndexOutOfBoundsException e) {</div>
<div style="color: #508f73; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// <span style="color: #92b0c9;">TODO</span> Auto-generated catch block</div>
<div style="color: #3b3ffb; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="color: #0a30c8;">log</span><span style="color: black;">.error(</span>"Exception occured while invoking the mapper threads"</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ e.toString());</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="color: #508f73; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// System.out.println("ContentLength:::"+contentLengthPerThread);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} <span style="color: #921f67;">catch</span> (InterruptedException e) {</div>
<div style="color: #508f73; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// <span style="color: #92b0c9;">TODO</span> Auto-generated catch block</div>
<div style="color: #3b3ffb; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="color: #0a30c8;">log</span><span style="color: black;">.error(</span>"Exception occured while invoking the mapper threads"</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ e.toString());</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">return</span> wordCountMap;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">private</span> <span style="color: #921f67;">int</span> getContentLengthPerThread(<span style="color: #921f67;">int</span> numberOfThreads,</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> inputWordsList) {</div>
<div style="color: #508f73; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// <span style="color: #92b0c9;">TODO</span> Auto-generated method stub</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">int</span> contentLengthPerThread = 0;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">if</span> (numberOfThreads == 0) {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>contentLengthPerThread = 1;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>numberOfThreads = 1;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} <span style="color: #921f67;">else</span> {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>contentLengthPerThread = inputWordsList.size() / numberOfThreads;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">if</span> (contentLengthPerThread == 0) {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>contentLengthPerThread = inputWordsList.size();</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">return</span> contentLengthPerThread;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">private</span> List<String> getInputList(BufferedReader br) <span style="color: #921f67;">throws</span> IOException {</div>
<div style="color: #508f73; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// <span style="color: #92b0c9;">TODO</span> Auto-generated method stub</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>ArrayList<String> inputWordsList = <span style="color: #921f67;">new</span> ArrayList<String>();</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>String tempInputWord = <span style="color: #921f67;">null</span>;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">while</span> ((tempInputWord = br.readLine()) != <span style="color: #921f67;">null</span>) {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>inputWordsList.add(tempInputWord);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">return</span> inputWordsList;</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>/**</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * Method to display word counts</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * </div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * <span style="color: #92b0c9;">@param</span> wordCountMap</div>
<div style="color: #5178c8; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> */</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">public</span> <span style="color: #921f67;">void</span> displayWordCounts(Map<String, Integer> wordCountMap) {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>Iterator wordCountsIter = wordCountMap.keySet().iterator();</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="color: #3b3ffb; font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.</span><span style="color: #0a30c8;">out</span><span style="color: black;">.println(</span>"WordName"<span style="color: black;"> + </span>" :: :: "<span style="color: black;"> + </span>"WordCount"<span style="color: black;">);</span></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">while</span> (wordCountsIter.hasNext()) {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>String inputWord = (String) wordCountsIter.next();</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.<span style="color: #0a30c8;">out</span>.println(inputWord + <span style="color: #3b3ffb;">" :: :: "</span></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ wordCountMap.get(inputWord));</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">public</span> <span style="color: #921f67;">static</span> <span style="color: #921f67;">void</span> main(String[] args) {</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>WordCountProcessor wcp = <span style="color: #921f67;">new</span> WordCountProcessor();</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>wcp.processMapAndReduce(<span style="color: #3b3ffb;">"sample.txt"</span>);</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 15px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
}</div>
<div style="text-decoration: underline;">
<br /></div>
</b></span></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<div style="color: black; font-family: sans-serif; font-size: 13px;">
<b><u>Step2:Define the WordCountMapper to Map the words</u></b></div>
<div style="color: black; font-family: sans-serif; font-size: 13px;">
<b><u><br /></u></b><b><u>WordCountMapper.java</u></b></div>
<div style="color: black; font-family: sans-serif; font-size: 13px;">
<b><u><br /></u></b></div>
<br />
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="color: #921f67; font-family: Times; font-size: small;"><b><br /></b></span></div>
</div>
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b></b></span><br />
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">package</span> com.example.java.concurrency.wordcount;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><br /></b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">import</span> <span style="text-decoration: underline;">java.io.InputStream</span>;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">import</span> java.util.HashMap;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">import</span> java.util.List;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">import</span> java.util.Map;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">import</span> java.util.StringTokenizer;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">import</span> java.util.concurrent.Callable;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">import</span> <span style="text-decoration: underline;">java.util.concurrent.ThreadPoolExecutor</span>;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><br /></b></span></div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b>/**</b></span></div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b> * This class is used to map the input words by creating a map of all input words along with their </b></span></div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b> * count of <span style="text-decoration: underline;">occurence</span>.</b></span></div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b> * <span style="color: #92b0c9;">@author</span> <span style="text-decoration: underline;">raghuramgururajan</span></b></span></div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b> *</b></span></div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b> */</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: #921f67;">public</span> <span style="color: #921f67;">class</span> WordCountMapper <span style="color: #921f67;">implements</span> Callable<WordCountStatus> {</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">private</span> <span style="color: #921f67;">static</span> <span style="color: #921f67;">final</span> CharSequence <span style="color: #0a30c8;">PATTERN_COMMA</span> = <span style="color: #3b3ffb;">","</span>;</b></span></div>
<div style="color: #921f67; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>private<span style="color: black;"> </span>static<span style="color: black;"> </span>final<span style="color: black;"> String </span><span style="color: #0a30c8;">PATTERN_SPACE</span><span style="color: black;"> = </span><span style="color: #3b3ffb;">" "</span><span style="color: black;">;</span></b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">private</span> <span style="color: #921f67;">static</span> <span style="color: #921f67;">final</span> CharSequence <span style="color: #0a30c8;">PATTERN_EMPTY_STRING</span> = <span style="color: #3b3ffb;">""</span>;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">private</span> <span style="color: #921f67;">static</span> <span style="color: #921f67;">final</span> CharSequence <span style="color: #0a30c8;">PATTERN_DOT</span> = <span style="color: #3b3ffb;">"."</span>;</b></span></div>
<div style="color: #921f67; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>private<span style="color: black;"> </span>static<span style="color: black;"> </span>final<span style="color: black;"> Integer </span><span style="color: #0a30c8;">FIRST_OCCURENCE</span><span style="color: black;"> = 1;</span></b></span></div>
<div style="color: #921f67; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>private<span style="color: black;"> </span>static<span style="color: black;"> </span>final<span style="color: black;"> </span>int<span style="color: black;"> </span><span style="color: #0a30c8;">LENGTH_ONE</span><span style="color: black;"> = 1;</span></b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">private</span> List<String> <span style="color: #0a30c8;">inputWordsList</span>=<span style="color: #921f67;">null</span>;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">public</span> WordCountMapper(List<String> inputWordsList)</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">this</span>.<span style="color: #0a30c8;">inputWordsList</span>=inputWordsList;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">public</span> WordCountStatus call() <span style="color: #921f67;">throws</span> Exception {</b></span></div>
<div style="color: #508f73; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// <span style="color: #92b0c9;">TODO</span> Auto-generated method stub</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>WordCountStatus ws=<span style="color: #921f67;">new</span> WordCountStatus();</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>Map<String,Integer> inputWordsMap=<span style="color: #921f67;">new</span> HashMap<String,Integer>();</b></span></div>
<div style="color: #508f73; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>//Iterate over the inputWordsList and create a intermediate map with counts</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">for</span>(String inputWords:<span style="color: #0a30c8;">inputWordsList</span>)</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{<span class="Apple-tab-span" style="white-space: pre;"> </span></b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>StringTokenizer inputWordsTokens=<span style="color: #921f67;">new</span> StringTokenizer(inputWords,<span style="color: #0a30c8;">PATTERN_SPACE</span>);</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span></b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">while</span>(inputWordsTokens.hasMoreTokens())</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>String inputWordMapKey=inputWordsTokens.nextToken();</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span></b></span></div>
<div style="color: #508f73; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>//Filter and remove commas and empty spaces</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">if</span>(inputWordMapKey!=<span style="color: #921f67;">null</span> && inputWordMapKey.length() > <span style="color: #0a30c8;">LENGTH_ONE</span>)</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">if</span>(inputWordMapKey.contains(<span style="color: #0a30c8;">PATTERN_COMMA</span>))</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>inputWordMapKey=inputWordMapKey.replace(<span style="color: #0a30c8;">PATTERN_COMMA</span>,<span style="color: #0a30c8;">PATTERN_EMPTY_STRING</span>);</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">if</span>(inputWordMapKey.contains(<span style="color: #0a30c8;">PATTERN_DOT</span>))</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>inputWordMapKey=inputWordMapKey.replace(<span style="color: #0a30c8;">PATTERN_DOT</span>,<span style="color: #0a30c8;">PATTERN_EMPTY_STRING</span>);</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div style="color: #508f73; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>//If the map is not empty and if the map already contains the word increment</b></span></div>
<div style="color: #508f73; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>//the counter</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>inputWordMapKey=inputWordMapKey.toLowerCase();</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">if</span>(!inputWordsMap.isEmpty() && inputWordsMap.containsKey(inputWordMapKey))</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">int</span> wordCount=inputWordsMap.get(inputWordMapKey);</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>wordCount++;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>inputWordsMap.put(inputWordMapKey, wordCount);</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">else</span></b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>inputWordsMap.put(inputWordMapKey, <span style="color: #0a30c8;">FIRST_OCCURENCE</span>);</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span></b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div style="color: #508f73; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>//Validate the map to see if its empty or not</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">if</span>(!inputWordsMap.isEmpty())</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>ws.setInputWordsMap(inputWordsMap);</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span></b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">return</span> ws;</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span></b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><br /></b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b>}</b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><br /></b></span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b><br /></b></span></div>
</div>
<span class="Apple-style-span" style="color: black; font-family: Times; font-size: small; line-height: normal;"><b>
</b></span><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px;"><b><u>Step3:Define the WordCountStatus to hold the return type of WordCountMapper</u></b></span></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; font-style: normal; font-variant: normal; letter-spacing: normal; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small; line-height: 19.200000762939453px;"><b><u><br /></u></b></span><span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; line-height: normal;"><b></b></span>
<br />
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
</div>
<span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; line-height: normal;"><b>
</b></span>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; line-height: normal;"><b><span style="color: #921f67;">package</span> com.example.java.concurrency.wordcount;</b></span></div>
<span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; line-height: normal;"><b>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<br /></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: #921f67;">import</span> <span style="text-decoration: underline;">java.util.HashMap</span>;</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: #921f67;">import</span> java.util.Map;</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<br /></div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
/**</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
* Class to store the status of all the intermediate tasks and act</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
* as an input for reducer for final word count computation</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
* <span style="color: #92b0c9;">@author</span> <span style="text-decoration: underline;">raghuramgururajan</span></div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
*</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
*/</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: #921f67;">public</span> <span style="color: #921f67;">class</span> WordCountStatus {</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">private</span> Map<String,Integer> <span style="color: #0a30c8;">inputWordsMap</span>=<span style="color: #921f67;">null</span>;</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<br /></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">public</span> Map<String, Integer> getInputWordsMap() {</div>
<div style="color: #0a30c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="color: #921f67;">return</span><span style="color: black;"> </span>inputWordsMap<span style="color: black;">;</span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<br /></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">public</span> <span style="color: #921f67;">void</span> setInputWordsMap(Map<String, Integer> inputWordsMap) {</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">this</span>.<span style="color: #0a30c8;">inputWordsMap</span> = inputWordsMap;</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<br /></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
}</div>
<div>
<br /></div>
</b></span><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19.200000762939453px;"><b><u><div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 19.200000762939453px; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px;"><b><u><br /></u></b></span></div>
Step4:Define the WordCountReducer to reduce the map and produce the final word count </u></b></span><br />
<div style="line-height: 19.200000762939453px;">
</div>
<div style="line-height: 19.200000762939453px;">
<span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small;"><b><u><br /></u></b></span></div>
<div style="line-height: 19.200000762939453px;">
<span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: normal;"><b></b></span></div>
<div style="font: normal normal normal 11px/normal Monaco; line-height: 19.200000762939453px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<b><span style="color: #921f67;">package</span> com.example.java.concurrency.wordcount;</b></div>
<b>
</b>
<br />
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<b><br /></b></div>
<b>
</b>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<b><span style="color: #921f67;">import</span> java.util.HashMap;</b></div>
<b>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: #921f67;">import</span> java.util.Iterator;</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: #921f67;">import</span> java.util.List;</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: #921f67;">import</span> java.util.Map;</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: #921f67;">import</span> java.util.concurrent.ExecutionException;</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: #921f67;">import</span> java.util.concurrent.Future;</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<br /></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: #921f67;">import</span> org.apache.log4j.Logger;</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
/**</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
* Class to basically reduce all the intermediate output to produce final output</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
* <span style="color: #92b0c9;">@author</span> <span style="text-decoration: underline;">raghuramgururajan</span></div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
*</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
*/</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: #921f67;">public</span> <span style="color: #921f67;">class</span> WordCountReducer {</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<br /></div>
<div style="color: #921f67; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>private<span style="color: black;"> </span>static<span style="color: black;"> </span>final<span style="color: black;"> Integer </span><span style="color: #0a30c8;">FIRST_OCCURENCE</span><span style="color: black;"> = 1;</span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">private</span> <span style="color: #921f67;">static</span> Logger <span style="color: #0a30c8;">log</span> = Logger.getLogger(</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>WordCountReducer.<span style="color: #921f67;">class</span>.getName());</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>/**</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * Method to basically reduce all the intermediate output to produce final output</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> * <span style="color: #92b0c9;">@param</span> wordCountFutureList</div>
<div style="color: #92b0c9; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: #5178c8;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * </span>@return</div>
<div style="color: #5178c8; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> */</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">public</span> Map<String,Integer> reduce(List<Future<WordCountStatus>> wordCountFutureList) {</div>
<div style="color: #508f73; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// <span style="color: #92b0c9;">TODO</span> Auto-generated method stub</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>Map<String,Integer> wordCountMap=<span style="color: #921f67;">new</span> HashMap<String,Integer>();</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">try</span> {</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">for</span>(Future<WordCountStatus> future:wordCountFutureList)</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>Map<String,Integer> tempWordCountMap=future.get().getInputWordsMap();</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="text-decoration: underline;">Iterator</span> wordMapIter=tempWordCountMap.keySet().iterator();</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">while</span>(wordMapIter.hasNext())</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>String inputWord=(String) wordMapIter.next();</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">if</span>(wordCountMap.isEmpty()|| !wordCountMap.containsKey(inputWord))</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>wordCountMap.put(inputWord, <span style="color: #0a30c8;">FIRST_OCCURENCE</span>);</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">else</span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> </div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">int</span> occurence=wordCountMap.get(inputWord);</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>occurence++;</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>wordCountMap.put(inputWord, occurence);</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} <span style="color: #921f67;">catch</span> (InterruptedException e) {</div>
<div style="color: #508f73; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// <span style="color: #92b0c9;">TODO</span> Auto-generated catch block</div>
<div style="color: #3b3ffb; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="color: #0a30c8;">log</span><span style="color: black;">.error(</span>"Error occured in WordCountReducer"<span style="color: black;">+e.toString());</span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} <span style="color: #921f67;">catch</span> (ExecutionException e) {</div>
<div style="color: #508f73; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>// <span style="color: #92b0c9;">TODO</span> Auto-generated catch block</div>
<div style="color: #3b3ffb; font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span style="color: black;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="color: #0a30c8;">log</span><span style="color: black;">.error(</span>"Error occured in WordCountReducer"<span style="color: black;">+e.toString());</span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<br /></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #921f67;">return</span> wordCountMap;</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 15.0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
}</div>
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<br /></div>
</b><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px;"><b><u>Step5:Sample Output of WordCount</u></b></span></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small;"><span class="Apple-style-span" style="line-height: 19px;"><b><u><br /></u></b></span></span></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small;"><span class="Apple-style-span" style="line-height: 19px;"><b></b></span></span><br />
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small;"><span class="Apple-style-span" style="line-height: 19px;"><b>::::::::::::::::::::::Calling Mapper to map the words::::::::::::::::::::::::::::::::</b></span></span></div>
<span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small;"><span class="Apple-style-span" style="line-height: 19px;"><b>
</b></span></span>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small;"><span class="Apple-style-span" style="line-height: 19px;"><b>12.5% mapping complete</b></span></span></div>
<span class="Apple-style-span" style="font-family: sans-serif; font-size: x-small;"><span class="Apple-style-span" style="line-height: 19px;"><b>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
25.0% mapping complete</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
37.5% mapping complete</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
50.0% mapping complete</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
62.5% mapping complete</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
75.0% mapping complete</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
87.5% mapping complete</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
100.0% mapping complete</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
::::::::::::::::::::Calling reducer to reduce the words::::::::::::::::::::::::::::::::</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
::::::::::::::::::::The word count is ::::::::::::::::::::</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
WordName :: :: WordCount</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
bandanna :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
forth :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
need :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
holding :: :: 2</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
mentonsolicitor :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
for :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
coffey :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
round :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
defunct :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
him :: :: 2</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
must :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
didn't :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
of :: :: 4</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
twisted :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
looks :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
sleepily :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
bachelor's :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
she :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
poppies :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
her :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
chaplain :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
portly :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
awfully :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
heart :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
once :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
how :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
oaths :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
he :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
27 :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
toadbellied :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
and :: :: 2</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
that :: :: 2</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
now :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
bearing :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
affidavits :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
lines :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
tied :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
walk :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
wall :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
satisfy :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
buttermilk :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
john :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
wrynecked :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
nightcap :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
father :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
was :: :: 2</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
staff :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
caretaker :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
figure :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
me :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
bunch :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
hard :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
animal :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
hypertrophied :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
with :: :: 2</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
is :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
it :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
mr :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
keys :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
surplice :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
poor :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
the :: :: 3</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
o'connell :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
j :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
bottle :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
in :: :: 2</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
employ :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
h :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
up :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
crape :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
beside :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
stands :: :: 2</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
am :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
wife :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
an :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
off :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
lamp :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
commissioner :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
sherry :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
cut :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
agree :: :: 1</div>
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
keep :: :: 1</div>
<div style="text-decoration: underline;">
<br /></div>
</b></span></span><b style="line-height: 19.200000762939453px;"><div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;">
<br /></div>
<br />
</b></div>
<div style="line-height: 19.200000762939453px;">
</div>
</div>
Anonymoushttp://www.blogger.com/profile/05317963248286212417noreply@blogger.com0