分享

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

liu6182169 发表于 2015-11-17 12:07:53 [显示全部楼层] 只看大图 回帖奖励 阅读模式 关闭右栏 3 11923
如题:
我用hadoop2.7.0测试wordcount的时候报错(我用的win环境)
for (IntWritable val : values) {
                                sum += val.get();
                        }

Type mismatch: cannot convert from element type Object to IntWritable

QQ截图20151117120452.png QQ截图20151117120507.png

已有(3)人评论

跳转到指定楼层
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);
                }
        }
回复

使用道具 举报

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 15:29:47
回复

使用道具 举报

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

本版积分规则

关闭

推荐上一条 /2 下一条