Reputation: 675
Why do we need to explicitly set OutputKey/InputKey Class in MapReduce job when the Map and Reduce classes has to extend Mapper and Reducer classes respectfully that requires to add <InputKeyClass, InputValueClass, OuputKeyClass, OutputValueClass>
?
an example:
JobConf:
job.setOutputKeyClass(NullWritable.class);
job.setOutputValueClass(Text.class);
job.setOutputFormatClass(TextOutputFormat.class);
Reducer:
public static class ComputeReducer extends
Reducer<Text, Text, NullWritable, Text> {
If we are already explicitly setting the reducer class to extend 'Reducer <Text, Text, NullWritable, Text>'
then why is it required to pass the OutputKey/value class?
Upvotes: 0
Views: 71
Reputation: 1266
You have to do that because all generic information is lost at run time in java.
Upvotes: 3