我正在尝试从 IntelliJ 内部运行 Map-Reduce 作业。这是我的运行者代码,
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,那么我做错了什么?
最佳答案
看看这些类来自哪些包。您可能正在混合包,并且需要根据您的 Hadoop 版本使用正确包中的 TextInputFormat。如果您使用的是 Hadoop 版本 2.x,那么与 Hadoop 版本 1.x(具有 mapred 包)相比,您需要导入不同的类(来自 mapreduce 包)
关于java - IntelliJ 中的 Mapreduce 作业失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41663950/