求助:我用hadoop2.7.0测试wordcount的时候报错

查看数: 11926 | 评论数: 3 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2015-11-17 12:07

正文摘要:

如题: 我用hadoop2.7.0测试wordcount的时候报错(我用的win环境) for (IntWritable val : values) {                             &nb ...

回复

liu6182169 发表于 2015-11-17 15:29:47
arsenduan 发表于 2015-11-17 12:31:29
liu6182169 发表于 2015-11-17 12:09
整段代码是这样子的:
        public static class IntSumReducer extends
                        Reducer {

   添加下面红字部分
public static class IntSumReducer extends
                        Reducer<Text, IntWritable, Text, IntWritable> {
                private IntWritable result = new IntWritable();

                public void reduce(Text key, Iterable<IntWritable > values, Context context)
                                throws IOException, InterruptedException {
                        int sum = 0;
                        for (IntWritable val : values) {
                                sum += val.get();
                        }
                        sum=100;
                        result.set(sum);
                        context.write(key, result);
                }
        }

liu6182169 发表于 2015-11-17 12:09:41
整段代码是这样子的:
        public static class IntSumReducer extends
                        Reducer<Text, IntWritable, Text, IntWritable> {
                private IntWritable result = new IntWritable();

                public void reduce(Text key, Iterable values, Context context)
                                throws IOException, InterruptedException {
                        int sum = 0;
                        for (IntWritable val : values) {
                                sum += val.get();
                        }
                        sum=100;
                        result.set(sum);
                        context.write(key, result);
                }
        }
关闭

推荐上一条 /2 下一条