Java IntWritable.set(IntWritable)正在引发错误
在编写示例代码以测试hadoop中的customdata时。我得到以下错误: IntWritable类型中的方法集(int)不适用于 参数(可写) 我已经检查了Java IntWritable.set(IntWritable)正在引发错误,java,hadoop,dictionary,reduce,Java,Hadoop,Dictionary,Reduce,在编写示例代码以测试hadoop中的customdata时。我得到以下错误: IntWritable类型中的方法集(int)不适用于 参数(可写) 我已经检查了intwriteable.set(int值)的set方法。 如何将hadoopintwriteable转换为Int,然后返回到intwriteable?#set方法将转换回intwriteable public class customText implements Writable{ private Text depName; //
intwriteable.set(int值)
的set
方法。
如何将hadoopintwriteable
转换为Int
,然后返回到intwriteable?#set
方法将转换回intwriteable
public class customText implements Writable{
private Text depName;
//default constr
private IntWritable depId;
customText(){
this.depName = new Text();
this.depId = new IntWritable();
}
customText(Text depName , IntWritable depId ){
this.depName.set(depName);
this.depId.set(depId);
我也尝试了this.depid=depid
,但没有成功
谢谢应该是:
customText(Text depName , IntWritable depId ){
this.depName.set(depName);
this.depId.set(depId.get());
}
set的方法签名是
set(int-value)
,因此您必须get()
从intwriteable
获取int?真的,你应该在发帖之前查阅文档。再次感谢@Binary Nerd的帮助
public class customText implements Writable{
private Text depName;
//default constr
private IntWritable depId;
customText(){
this.depName = new Text();
this.depId = new IntWritable();
}
customText(Text depName , IntWritable depId ){
this.depName.set(depName);
this.depId.set(depId);