0
我的代碼執行期間,我的map()函數似乎沒有被調用,我不明白爲什麼。下面是我工作的類...沒有調用Hadoop map()函數
public class MyHadoopJob extends Configured implements Tool{
static class MyMapper extends Mapper<LongWritable, Text, LongWritable, Text>{
public MyMapper(){
System.out.println("Mapper init!");
}
@Override
protected void map(LongWritable key, Text value,
org.apache.hadoop.mapreduce.Mapper<LongWritable, Text, LongWritable, Text>.Context context)
throws java.io.IOException, InterruptedException {
System.out.println("MAP!");
context.getCounter("mygroup", "jeff").increment(1);
context.write(key, value);
};
}
@Override
public int run(String[] strings) throws Exception {
Configuration conf = MYOBJ.getHadoopConf();
this.setConf(conf);
Job job = new Job(conf, "MyJob");
job.setJarByClass(MyHadoopJob.class);
job.setMapperClass(MyMapper.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
job.setMapOutputKeyClass(LongWritable.class);
job.setMapOutputValueClass(Text.class);
FileInputFormat.setInputPaths(job, new Path(strings[0]));
FileOutputFormat.setOutputPath(job, new Path(strings[1]));
job.waitForCompletion(true);
for(int i = 0; i < 10; i++){
log.info("Progress -> " + job.mapProgress());
Thread.sleep(15000);
}
return 0;
}
}
我真的很感激一些幫助搞清楚爲什麼地圖()類或確實類的初始化永遠不會叫什麼名字?
當你完成作業時你看到了什麼? –