Added code for hadoop.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.io.IntWritable;
|
||||
import org.apache.hadoop.io.Text;
|
||||
import org.apache.hadoop.mapreduce.Reducer;
|
||||
|
||||
public class CharacterCountReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
|
||||
private IntWritable result = new IntWritable();
|
||||
|
||||
@Override
|
||||
protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
|
||||
int count = 0;
|
||||
for (IntWritable val : values) {
|
||||
count += val.get();
|
||||
}
|
||||
result.set(count);
|
||||
context.write(key, result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user