初学mapReduce中job中的属性设置小错误

入门HadoopMapReduce的时候,用一个给定的log文件做数据清洗的时候,
run方法出现了小错误,找了很久(一直以为自己设置正确了)
run 方法

public int run(String[] args) throws Exception {
        // TODO Auto-generated method stub
        // final Job job = new Job(new Configuration(),
        // LogMapReduce.class.getSimpleName());
        // 工作在这个配置到文件系统下
        // Configuration configuration = super.getConf();
        Configuration configuration = new Configuration();
        Job job = Job.getInstance(configuration);
        // 执行到jar文件就是当前类,因为下面还要写一个main方法
        job.setJarByClass(MyMapReduce.class);
        // 设置传入和输出路径
        Path inPath = new Path(args[0]);
        Path outPath = new Path(args[1]);
        // 将路径配置到job中
        FileInputFormat.addInputPath(job, inPath);
        FileSystem fileSystem = FileSystem.get(configuration);
        // FileSystem fileSystem = FileSystem.get(new URI(args[0]), getConf());
        if (fileSystem.exists(outPath)) {
            fileSystem.delete(outPath, true);// 防止报错
        }
        FileOutputFormat.setOutputPath(job, outPath);
        // 设置map函数
        job.setMapperClass(MyMap.class);
        job.setMapOutputKeyClass(LongWritable.class);
        job.setMapOutputValueClass(Text.class);
        // 设置rudece函数
        job.setReducerClass(MyReduce.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);
        // 返回
        boolean waitForCompletion = job.waitForCompletion(true);
        System.out.println(waitForCompletion);
        return waitForCompletion ? 0 : 1;
    }

其中要设置map和reduce的输入类型,由于其中一个设置错误,导致map无法正确的写入到环形缓冲区中,实际上就是无法执行map方法中的context.write()方法。

细节决定成败,加油。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容