数据序列化格式选择几个特征

587 阅读1分钟

数据序列化格式选择几个重要特征:

  1. Code generation(代码生成);
  2. Schema evolution(架构演变):能满足修改数据模型的需求(增删改),前后兼容;
  3. Language support(语言支持):主流语言支持;
  4. Transparent compression(透明压缩):在「写/读」数据格式时,内部「压缩/解压」,不用自己管理压缩解压过程;
  5. Splittability(分割性):能分割,从而并行处理。文件格式包含同步标记至关重要;
  6. Supprot in MapReduce and the Hadoop ecosystem(支持 MapReduce 和 Hadoop 生态)

Feature comparison of data serialization frameworks

Feature comparison of data serialization frameworks


Avro

Apache Avro 是一个独立于编程语言的数据序列化系统。

Avro 与 Apache Thrift 和 Google Protocol Buffers相比:
相同点:语言无关
不同点:Avro 代码生成可选,可以遵循指定模式的数据进行「读/写」操作。

Avro 通常用 JSON 来写,数据通常采用二进制格式编码,还有高级语言 Avro IDL。

Avro
type
Generic Java mapping Specific Java mapping Reflect Java mapping
null null type
boolean boolean
int int bytem, short, int
long long
float float
double double
bytes java.nio.ByteBuffer Array of bytes
string org.apache.avro.util.Utf8 or
java.lang.String
java.lang.String
array org.apache.avro.generic.GenericArray Array or java.util.Collection
map java.util.Map
record org.apache.avro.generic.GenericRecord Generated class implementing
org.apache.avro.specific.SpecificRecord
Arbitrary user class with constructor;
all inherited instance fields are used
enum java.lang.String Generated Java enum Arbitrary Java enum
fixed org.apache.avro.generic.GenericFixed Generated class implementing
org.apache.avro.specific.SpecificFixed
org.apache.avro.generic.genericFixed
union java.lang.Object