|
@@ -84,7 +84,7 @@ import org.apache.hadoop.mapred.RawKeyValueIterator;
|
|
*
|
|
*
|
|
* <p>In this phase the
|
|
* <p>In this phase the
|
|
* {@link #reduce(Object, Iterable, Context)}
|
|
* {@link #reduce(Object, Iterable, Context)}
|
|
- * method is called for each <code><key, (collection of values)></code> in
|
|
|
|
|
|
+ * method is called for each <code><key, (collection of values)></code> in
|
|
* the sorted inputs.</p>
|
|
* the sorted inputs.</p>
|
|
* <p>The output of the reduce task is typically written to a
|
|
* <p>The output of the reduce task is typically written to a
|
|
* {@link RecordWriter} via
|
|
* {@link RecordWriter} via
|
|
@@ -96,18 +96,18 @@ import org.apache.hadoop.mapred.RawKeyValueIterator;
|
|
*
|
|
*
|
|
* <p>Example:</p>
|
|
* <p>Example:</p>
|
|
* <p><blockquote><pre>
|
|
* <p><blockquote><pre>
|
|
- * public class IntSumReducer<Key> extends Reducer<Key,IntWritable,
|
|
|
|
- * Key,IntWritable> {
|
|
|
|
|
|
+ * public class IntSumReducer<Key> extends Reducer<Key,IntWritable,
|
|
|
|
+ * Key,IntWritable> {
|
|
* private IntWritable result = new IntWritable();
|
|
* private IntWritable result = new IntWritable();
|
|
*
|
|
*
|
|
- * public void reduce(Key key, Iterable<IntWritable> values,
|
|
|
|
- * Context context) throws IOException {
|
|
|
|
|
|
+ * public void reduce(Key key, Iterable<IntWritable> values,
|
|
|
|
+ * Context context) throws IOException, InterruptedException {
|
|
* int sum = 0;
|
|
* int sum = 0;
|
|
* for (IntWritable val : values) {
|
|
* for (IntWritable val : values) {
|
|
* sum += val.get();
|
|
* sum += val.get();
|
|
* }
|
|
* }
|
|
* result.set(sum);
|
|
* result.set(sum);
|
|
- * context.collect(key, result);
|
|
|
|
|
|
+ * context.write(key, result);
|
|
* }
|
|
* }
|
|
* }
|
|
* }
|
|
* </pre></blockquote></p>
|
|
* </pre></blockquote></p>
|