在“Designing Data-Intensive Applications - CHAPTER 4 Encoding and Evolution - Formats for Encoding Data - Avro”中,举例展示了 Avro 如何进行编码。
示例记录如下:
{
"userName": "Martin",
"favoriteNumber": 1337,
"interests": ["daydreaming", "hacking"]
}
使用 Avro 编写的示例模式如下:
record Person {
string userName;
union { null, long } favoriteNumber = null;
array<string> interests;
}
示例记录被 Avro 编码之后为:

我的疑问
- 第一个字节
0x0c的最后一位代表 sign,sign 是什么呢? - 第八个字节
0x02代表union branch 1 (long, not null),怎么理解union branch 1 (long, not null)?
P.S. 因为是第一次接触 Avro,不太清楚应该怎么搜索相关信息,说实话,不太应该提这样的问题。