C3. Write a MapReduce driver program in Java for the given mapper and reducer classes that perform a word count on a data set stored in a text file. public class Map extends...


C3. Write a MapReduce driver program in Java for the given mapper and reducer classes that
perform a word count on a data set stored in a text file.
public class Map extends Mapper {
@Override
public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
String[] row = value.toString().split("\t");
context.write(new Text(row[2]),new IntWritable(1));
}
}
public class Reduce extends Reducer {
@Override
public void reduce(Text key, Iterable values, Context context)
throws IOException, InterruptedException {
int count = 0;
for (IntWritable value:values) {
count += value.get();
}
context.write(key, new IntWritable(count));
}
}



Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here