Jak serializować obiekt Java w Hadoop?
Obiekt powinien zostać zaimplementowanyWritable
interfejs, aby można go było serializować po przesłaniu w Hadoop. Weź LuceneScoreDoc
klasa jako przykład:
public class ScoreDoc implements java.io.Serializable {
/** The score of this document for the query. */
public float score;
/** Expert: A hit document's number.
* @see Searcher#doc(int) */
public int doc;
/** Only set by {@link TopDocs#merge} */
public int shardIndex;
/** Constructs a ScoreDoc. */
public ScoreDoc(int doc, float score) {
this(doc, score, -1);
}
/** Constructs a ScoreDoc. */
public ScoreDoc(int doc, float score, int shardIndex) {
this.doc = doc;
this.score = score;
this.shardIndex = shardIndex;
}
// A convenience method for debugging.
@Override
public String toString() {
return "doc=" + doc + " score=" + score + " shardIndex=" + shardIndex;
}
}
Jak mam go serializowaćWritable
berło? Jaki jest związek międzyWritable
ijava.io.serializable
berło?