2012-12-14 2 views

답변

8

방출 할 수있는 사용자 정의 유형을 매퍼 값으로 쓸 수 있습니다. 그러나 값으로 내보내려는 것이면 Writable Interface를 구현해야합니다. 다음과 같이 할 수 있습니다.

public class MyObj implements WritableComparable<MyObj>{ 

    private String date; 
    private Double balance; 

    public String getDate() { return date;} 
    public Double getBalance() { return balance;} 

    @Override 
    public void readFields(DataInput in) throws IOException { 

     //Define how you want to read the fields 
     } 
    @Override 
    public void writeFields(DataOutput out) throws IOException { 

     //Define how you want to write the fields 
    } 
     ....... 
     ....... 
     ....... 

} 

또는 Avro 직렬화 프레임 워크를 사용할 수 있습니다.

관련 문제