Commit ff95b518 authored by YUSHIQIAN's avatar YUSHIQIAN

implementation

parent 6a63c81b
......@@ -38,8 +38,8 @@
<file leaf-file-name="WordCountIMC.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/WordCountIMC.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.71005154" vertical-offset="289" max-vertical-offset="1785">
<caret line="56" column="72" selection-start-line="56" selection-start-column="72" selection-end-line="56" selection-end-column="72" />
<state vertical-scroll-proportion="0.69072163" vertical-offset="289" max-vertical-offset="1800">
<caret line="55" column="46" selection-start-line="55" selection-start-column="46" selection-end-line="55" selection-end-column="46" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#1235#1253#0" expanded="true" />
......@@ -390,7 +390,15 @@
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<option name="time" value="3" />
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/WordCountIMC.java</url>
<line>38</line>
<properties />
<option name="timeStamp" value="3" />
</line-breakpoint>
</breakpoints>
<option name="time" value="4" />
</breakpoint-manager>
<watches-manager />
</component>
......@@ -443,8 +451,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/WordCountIMC.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.71005154" vertical-offset="289" max-vertical-offset="1785">
<caret line="56" column="72" selection-start-line="56" selection-start-column="72" selection-end-line="56" selection-end-column="72" />
<state vertical-scroll-proportion="0.69072163" vertical-offset="289" max-vertical-offset="1800">
<caret line="55" column="46" selection-start-line="55" selection-start-column="46" selection-end-line="55" selection-end-column="46" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#1235#1253#0" expanded="true" />
......
......@@ -24,7 +24,7 @@ public class WordCountIMC extends Configured implements Tool {
static class WCMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
private IntWritable ONE = new IntWritable(1);
private IntWritable sum = new IntWritable(1);
private Text textValue = new Text();
@Override
......@@ -36,7 +36,7 @@ public class WordCountIMC extends Configured implements Tool {
String line = value.toString();
String[] words = line.split("\\s+");
for(String word : words) {
textValue.set(word);
if (map.containsKey(word)) {
map.put(word, map.get(word) + 1);
......@@ -51,8 +51,9 @@ public class WordCountIMC extends Configured implements Tool {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
context.write(pair.getKey(), pair.getValue());
textValue.set(pair.getKey());
sum.set(pair.getValue());
context.write(textValue, sum);
it.remove(); // avoids a ConcurrentModificationException
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment