java - IntelliJ 中的 Mapreduce 作业失败

标签 java hadoop intellij-idea mapreduce

我正在尝试从 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/

相关文章:

java - fragment bundle : NullPointerException

java - 在带有HBase的hadoop中使用外部jar

java - IntelliJ 静态 Web 项目到 Tomcat 或 Angular COR

groovy - IntelliJ Groovy 版本

javascript - Intellij Javascript 多行结构搜索和替换

java - 读取文本文件 - 在每一行的开头返回 null?

java - TwoSums 代码仅返回 [0,0]

java - 当我使用 close() 方法时,对象是否符合垃圾收集器的条件?

scala - 如何在我的 Spark 应用程序中使用 OpenHashSet?

r - RHadoop 中的 hdfs.init() 错误