0
我試圖從IntelliJ內部運行Map-Reduce作業。這是我的亞軍代碼,IntelliJ內部的Mapreduce作業失敗
public class ViewCount extends Configured implements Tool{
@Override
public int run(String[] args) throws Exception {
Configuration conf = this.getConf();
Job job = Job.getInstance(conf);
job.setJobName("viewCount");
job.setJarByClass(ViewCount.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);
Path inputFilePath = new Path(args[0]);
Path outputFilePath = new Path(args[1]);
FileInputFormat.addInputPath(job, inputFilePath);
FileOutputFormat.setOutputPath(job, outputFilePath);
return job.waitForCompletion(true) ? 0:1;
}
public static void main(String[] args) throws Exception {
int exitCode = ToolRunner.run(new ViewCount(), args);
System.exit(exitCode);
}
該任務無法生成並顯示以下錯誤消息。
error: incompatible types: Job cannot be converted to JobConf
FileOutputFormat.setOutputPath(job, outputFilePath);
Apached文檔表明該方法實際上是一個工作而不是一個JobConf,所以我做錯了什麼?
這與IntelliJ無關 – Moira
您可能正在混合映射減少1和2個API。檢查您從哪裏導入FileOutputFormat。舊的mapreduce(org.apache.hadoop.mapred.FileOutputFormat)接受JobConf,而新的(org.apache.hadoop.mapreduce.lib.output.FileOutputFormat)接受Job作爲參數。 – Amit