Added code for hadoop.

This commit is contained in:
K
2025-10-12 23:38:15 +05:30
parent 9038747b35
commit 658a087c64
4 changed files with 145 additions and 0 deletions
+19
View File
@@ -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);
}
}