Avro
先看Avro 能提供我们什么?
。 丰富的数据结构:
。兼容的快速的二进制数据格式:
。 RPC
实现:
。Avro 依赖模式Schema来实现数据结构的定义。Avro数据以模式来读和写(文件或者网络),这样序列化时速度快。
。Avro的Schema 以JSON对象来描述。
。Avro提供了8种primitive type 和 6种Complex type。原始类型由JSON字符串来表示;复杂类型由不同的属性来定义。
。Avro支持2种序列化编码方式:Binary 和 JSON编码。
详细:
1. Primitive types
- null:no values
- boolean: a binary value
- int: 32-bit signed integer
- long: 64-bit signed integer
- float: single precision(32-bit) IEEE 754 floating-poing number
- double: doubule precision(64-bit) IEEE 754 floating-poing number
- bytes: sequence of 8-bit unsigned bytes
- string: unicode character sequence
原始类型没有特别属性,它的名字也就是它的类型名
2. Complex types
- Recoreds
- Enums
- Arrays
- Maps
- Unions
- Fixed
3. Avro RPC
Avro protocols 描述 RPC接口。如同Schema,也是以JSON文本串来描述,包含属性:
- protocol, a string ,the name of the protocol [required]
- namespace, a string that qualifies the name [optional]
- doc, a string describing this protocol [optional]
- types, a list of definitions of named types [optionsl]
- messages, a JSON object whose keys are message names and whose values are objects, and whose attrs ..[optiona]
Messages attributes:
- doc, optional
- request, 命名的参数列表
- response, schema
- error, optional,union of declared error schemas
其实protocol 就是定义rpc方法的,需要声明方法的方法名,参数名,参数类型,返回类型以及异常类型。
http://avro.apache.org/docs/current/spec.html
Avro @ python: avro.apache.org/docs/current/gettingstartedpython.html
https://pypi.python.org/pypi/avro
浙公网安备 33010602011771号