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
+21
View File
@@ -0,0 +1,21 @@
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
public class CharacterCountMapper extends Mapper<Object, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text character = new Text();
@Override
protected void map(Object key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString().toLowerCase();
for (char c : line.toCharArray()) {
if (Character.isAlphabetic(c)) {
character.set(String.valueOf(c));
context.write(character, one);
}
}
}
}