Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java IntWritable.set(IntWritable)正在引发错误_Java_Hadoop_Dictionary_Reduce - Fatal编程技术网

Java IntWritable.set(IntWritable)正在引发错误

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; //

在编写示例代码以测试hadoop中的customdata时。我得到以下错误:

IntWritable类型中的方法集(int)不适用于 参数(可写)

我已经检查了
intwriteable.set(int值)
set
方法。 如何将hadoop
intwriteable
转换为
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);