私はmap-reduceが初めてです。Hadoop でカスタム データ型を実装するときに、readfield と write メソッドをどのように使用するのか知りたいですか? 例えば、
public class Point3D implements Writable {
public float x;
public float y;
public float z;
public Point3D(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
}
public Point3D() {
this(0.0f, 0.0f, 0.0f);
}
public void write(DataOutput out) throws IOException {
out.writeFloat(x);
out.writeFloat(y);
out.writeFloat(z);
}
public void readFields(DataInput in) throws IOException {
x = in.readFloat();
y = in.readFloat();
z = in.readFloat();
}
public String toString() {
return Float.toString(x) + ", "
+ Float.toString(y) + ", "
+ Float.toString(z);
}
public void set(float x, float y, float z)
{
this.x=x;
this.y=y;
this.z=z;
}
}
上記の例では、カスタム レコードリーダーは set メソッドを使用して x、y、および z の値を設定します。最後に、マッパーでこれらの値を取得します。しかし、書き込み可能からの readfealds および write() メソッドの必要性は何ですか?? お願いします。ヘルプ