hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r749904 - in /hadoop/core/branches/branch-0.20: CHANGES.txt src/benchmarks/gridmix2/src/java/org/apache/hadoop/mapred/CombinerJobCreator.java
Date Wed, 04 Mar 2009 04:52:58 GMT
Author: cdouglas
Date: Wed Mar  4 04:52:58 2009
New Revision: 749904

URL: http://svn.apache.org/viewvc?rev=749904&view=rev
Log:
HADOOP-5274. Fix gridmix2 dependency on wordcount example.

Modified:
    hadoop/core/branches/branch-0.20/CHANGES.txt
    hadoop/core/branches/branch-0.20/src/benchmarks/gridmix2/src/java/org/apache/hadoop/mapred/CombinerJobCreator.java

Modified: hadoop/core/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/CHANGES.txt?rev=749904&r1=749903&r2=749904&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.20/CHANGES.txt Wed Mar  4 04:52:58 2009
@@ -676,6 +676,8 @@
 
     HADOOP-5111. Fix Job::set* methods to work with generics. (cdouglas)
 
+    HADOOP-5274. Fix gridmix2 dependency on wordcount example. (cdouglas)
+
 Release 0.19.2 - Unreleased
 
   BUG FIXES

Modified: hadoop/core/branches/branch-0.20/src/benchmarks/gridmix2/src/java/org/apache/hadoop/mapred/CombinerJobCreator.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/benchmarks/gridmix2/src/java/org/apache/hadoop/mapred/CombinerJobCreator.java?rev=749904&r1=749903&r2=749904&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/benchmarks/gridmix2/src/java/org/apache/hadoop/mapred/CombinerJobCreator.java
(original)
+++ hadoop/core/branches/branch-0.20/src/benchmarks/gridmix2/src/java/org/apache/hadoop/mapred/CombinerJobCreator.java
Wed Mar  4 04:52:58 2009
@@ -18,15 +18,51 @@
 
 package org.apache.hadoop.mapred;
 
-import org.apache.hadoop.examples.WordCount;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.LongWritable;
 import org.apache.hadoop.io.Text;
 
-public class CombinerJobCreator extends WordCount {
+public class CombinerJobCreator {
+
+   public static class MapClass extends MapReduceBase
+     implements Mapper<LongWritable, Text, Text, IntWritable> {
+
+     private final static IntWritable one = new IntWritable(1);
+     private Text word = new Text();
+
+     public void map(LongWritable key, Text value,
+                     OutputCollector<Text, IntWritable> output,
+                     Reporter reporter) throws IOException {
+       String line = value.toString();
+       StringTokenizer itr = new StringTokenizer(line);
+       while (itr.hasMoreTokens()) {
+         word.set(itr.nextToken());
+         output.collect(word, one);
+       }
+     }
+   }
+
+   public static class Reduce extends MapReduceBase
+     implements Reducer<Text, IntWritable, Text, IntWritable> {
+
+     public void reduce(Text key, Iterator<IntWritable> values,
+                        OutputCollector<Text, IntWritable> output,
+                        Reporter reporter) throws IOException {
+       int sum = 0;
+       while (values.hasNext()) {
+         sum += values.next().get();
+       }
+       output.collect(key, new IntWritable(sum));
+     }
+   }
 
   public static JobConf createJob(String[] args) throws Exception {
-    JobConf conf = new JobConf(WordCount.class);
+    JobConf conf = new JobConf(CombinerJobCreator.class);
     conf.setJobName("GridmixCombinerJob");
 
     // the keys are words (strings)



Mime
View raw message