gpt4 book ai didi

java - IntWritable.set(IntWritable) 抛出错误

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

在编写示例代码以测试 hadoop 中的自定义数据时。我收到以下错误:

The method set(int) in the type IntWritable is not applicable for the arguments (IntWritable)

我已经检查了 IntWritable.set(int value)set 方法。如何将 hadoop IntWritable 转换为 Int 然后返回 IntWritable#set 方法将转换回 IntWritable.

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() IntWritable 中的int。

关于java - IntWritable.set(IntWritable) 抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37771506/

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