gpt4 book ai didi

java - Hadoop - 未加载 IntWritable(int) 构造函数

转载 作者:可可西里 更新时间:2023-11-01 16:46:35 24 4
gpt4 key购买 nike

<分区>

我正在尝试在 Hadoop 中创建一个 MapReduce,并希望将它的 String 转换为 IntWritable。我遵循此处列出的建议:How to convert String object to IntWritable Object in Hadoop .它建议使用

new IntWriteable(Integer.parseInt(someString))

所以我正在尝试的是

public class MyMapper extends Mapper<LongWritable, Text, Text, IntWritable > {
private final Text wordKey = new Text("");

public void map(LongWritable ikey, Text value, Context context) throws IOException, InterruptedException {
String[] friend = value.toString().split(";");
String[] friendswith = friend[1].split(",");
for (String s : friendswith) {
wordKey.set(friend[0]);
context.write(wordKey, IntWritable(Integer.parseInt(s))); //trying to convert here
}
}
}

但是报错

The method IntWritable(int) is undefined for the type MyMapper

根据文档here它指出,有一个构造函数接受 int 作为输入。我确实导入了 IntWritable:

import org.apache.hadoop.io.IntWritable;

什么可能导致我无法使用 IntWritable(int) 构造函数?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com