Avro - acehippo/slowmotion GitHub Wiki
Reference
Apache Avro
Apache Avro™ is a data serialization system.
- Rich data structures.
- A compact, fast, binary data format.
- A container file, to store persistent data.
- Remote procedure call (RPC).
- Simple integration with dynamic languages. Code generation is not required to read or write data files nor to use or implement RPC protocols. Code generation as an optional optimization, only worth implementing for statically typed languages.
golang library for avro
import "github.com/linkedin/goavro"
func encode(record *goavro.Record) []byte {
codec, err := goavro.NewCodec(JSONSchema)
if err != nil {
fmt.Println(err.Error())
}
bb := new(bytes.Buffer)
if err := codec.Encode(bb, record); err != nil {
fmt.Println(err.Error())
}
return bb.Bytes()
}
func decode(data []byte) *goavro.Record {
codec, err := goavro.NewCodec(JSONSchema)
if err != nil {
fmt.Println(err.Error())
}
bb := bytes.NewBuffer(data)
decoded, _ := codec.Decode(bb)
record := decoded.(*goavro.Record)
return record
}