分享

Wordcount复制过来的函数,不知道为什么报错

a3087661 发表于 2015-4-24 17:04:07 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 6 50324
本帖最后由 a3087661 于 2015-4-24 17:06 编辑

Configuration conf = new Configuration();
    String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
    if (otherArgs.length != 2) {
      System.err.println("Usage: wordcount <in> <out>");
      System.exit(2);
    }
    Job job = new Job(conf, "ReduceSideJoin");
    job.setJarByClass(ReduceSideJoin.class);
    job.setMapperClass(MyMapper.class);
    //job.setCombinerClass(MyReducer.class);
    job.setReducerClass(MyReduce.class);
    job.setOutputKeyClass(IntWritable.class);
    job.setOutputValueClass(Person.class);
    FileInputFormat.addInputPath(job, new Path(otherArgs[0]));   //报错
    FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));//报错
    System.exit(job.waitForCompletion(true) ? 0 : 1);
报错:Exception in thread "main" java.lang.Error: Unresolved compilation problems:
        The method addInputPath(JobConf, Path) in the type FileInputFormat is not applicable for the arguments (Job, Path)
        The method setOutputPath(JobConf, Path) in the type FileOutputFormat is not applicable for the arguments (Job, Path)

已有(6)人评论

跳转到指定楼层
幻灭若水 发表于 2015-4-24 17:32:15
检查下FileInputFormat和FileOutputFormat  import的包是否出错
回复

使用道具 举报

langke93 发表于 2015-4-24 17:37:51
复制别人的一般都需要改改,增加些包。参考这个:

新手指导,该如何在开发环境中,创建mapreduce程序


回帖中的问题,也都有答案
回复

使用道具 举报

a3087661 发表于 2015-4-24 17:48:16
本帖最后由 a3087661 于 2015-4-24 17:57 编辑
幻灭若水 发表于 2015-4-24 17:32
检查下FileInputFormat和FileOutputFormat  import的包是否出错

刚才的问题解决完了。多谢



回复

使用道具 举报

a3087661 发表于 2015-4-24 17:53:31
本帖最后由 a3087661 于 2015-4-24 17:58 编辑
langke93 发表于 2015-4-24 17:37
复制别人的一般都需要改改,增加些包。参考这个:

新手指导,该如何在开发环境中,创建mapreduce程序

刚才的问题解决完了。多谢
回复

使用道具 举报

langke93 发表于 2015-4-24 23:50:58
a3087661 发表于 2015-4-24 17:53
刚才的问题解决完了。多谢

楼主怎么解决的,根据上面的例子??
回复

使用道具 举报

a3087661 发表于 2015-4-25 07:37:28
langke93 发表于 2015-4-24 23:50
楼主怎么解决的,根据上面的例子??

原来import的包是旧的api,换成新的就好了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条