我正在运行mapreduce程序,但我意识到虽然我写了一个reduce函数,但mapreduce并没有执行它。然后我尝试添加@Override
,错误说reduce函数没有覆盖任何超级方法。
作业配置信息如下
preProcess.setJobName("GeneProcessing program for 100 SNP");
preProcess.setMapperClass(PreprocessMapper.class);
preProcess.setReducerClass(PreprocessReducer.class);
preProcess.setInputFormatClass(TextInputFormat.class);
//setInputFormat(TextInputFormat.class);
preProcess.setOutputFormatClass(TextOutputFormat.class);
preProcess.setMapOutputKeyClass(Text.class);
preProcess.setMapOutputValueClass(Text.class);
preProcess.setOutputKeyClass(NullWritable.class);
preProcess.setOutputValueClass(Text.class);
//preProcess.setNumMapTasks(4);
preProcess.setNumReduceTasks(4);
FileInputFormat.setInputPaths(preProcess, preprocessInputPath);
FileOutputFormat.setOutputPath(preProcess, preprocessOutputPath);
//JobClient.runJob(preProcess);
preProcess.waitForCompletion(true);
减少代码如下
import java.io.*;
import java.util.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.Reducer;
public class PreprocessReducer extends Reducer<Text, Text, NullWritable, Text>
{
public Text newKey = new Text("");
//no enter the reduce task
@Override
protected void reduce(Text key, Iterator<Text> values, Context output)
throws IOException, InterruptedException
{
do something here
}
}