복붙노트

[HADOOP] 쓰기에서 빈 값 () 메소드 : 하둡 맵리 듀스에서 사용자 정의 데이터 유형

HADOOP

쓰기에서 빈 값 () 메소드 : 하둡 맵리 듀스에서 사용자 정의 데이터 유형

나는 키와 값으로 두 개의 2D 이중 배열을 방출하고있다. 나는 WritableComparable 클래스를 구성하고있다.

public class MF implements WritableComparable<MF>{

/**
 * @param args
 */
private double[][] value;

public MF() {
    // TODO Auto-generated constructor stub
}

public MF(double[][] value) {
    // TODO Auto-generated constructor stub

      this.value = new double[value.length][value[0].length];
    // System.out.println("in matrix");
}

public void set(double[][] value) {
      this.value = value;
}

public double[][] getValue() {
        return value;
}

@Override
public void write(DataOutput out) throws IOException {
    System.out.println("write");
    int row=0;
    int column=0;
    for(int i=0; i<value.length;i++) {
        row = value.length;
        for(int j=0; j<value[i].length; j++) {
            column = value[i].length;
        }
    }
    out.writeInt(row);
    out.writeInt(column);

    for(int i=0;i<row ; i++) {
        for(int j= 0 ; j< col;j++) {
            out.writeDouble(value[i][j]);
        }
    }

    for(int i =0;i< value.length ;i ++) {
        for(int j = 0;j <value[0].length;j++) {
            System.out.print(value[i][j]+ "\t");
        }
        System.out.println("");
    }
}

@Override
public void readFields(DataInput in) throws IOException {
    int row = in.readInt();
    int col = in.readInt();

    double[][] value = new double[row][col];
    for(int i=0;i<row ; i++) {
        for(int j= 0 ; j< col;j++) {
            value[i][j] = in.readDouble();
        }
    }
}

@Override
public int hashCode() {

}

@Override
public boolean equals(Object o) {

}

@Override
public int compareTo(MF o) {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public String toString() {
    System.out.println(Arrays.toString(value));
    return Arrays.toString(value);
}
}

내가 쓰기 메서드 내에서 내 매트릭스를 인쇄하려고 할 때 그리고 반까지, 매트릭스 값을 가지고 있지 않습니다

write
    0.0 0.0 0.0 
    0.0 0.0 0.0 
    0.0 0.0 0.0 
write
    0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 
    0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 
    0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 

내가 뭔가 잘못하고있는 중이 야. 나는 행과 COLS의 경향이 어떤을 얻고있다.

해결법

    from https://stackoverflow.com/questions/19674314/empty-value-in-write-method-custom-datatype-in-hadoop-mapreduce by cc-by-sa and MIT license