haoop序列化 Writable接口與WriteCompareable接口

public interface WritableComparable<T> extends Writable, Comparable<T> {
}

       Hadoop 並無使用 JAVA 的序列化,而是引入了本身實的序列化系統, package org.apache.hadoop.io 這個包中定義了大量的可序列化對象,這些對象都實現了 Writable 接口, Writable 接口是序列化對象的一個通用接口 .

咱們來看下Writable 接口的定義。java

public interface Writable{
void write(DataOutput out) throws IOException;
void readFields(DataInput in) throws IOException;
}

Writable接口抽象了兩個序列化的方法WriteReadFields,分別對應了序列化和反序列化,參數DataOutPut java.io包內的IO類,Writable接口只是對象序列化的一個簡單聲明。apache

  WriteCompareable接口oop


    WriteCompareable接口是Wirtable接口的二次封裝,提供了compareTo(T o)方法,用於序列化對象的比較的比較,下面是io包簡單的類圖關係。spa


相關文章
相關標籤/搜索