1 Star 0 Fork 0

kabitionno/go-avro

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vars.go 3.80 KB
一键复制 编辑 原始数据 按行查看 历史
dt-mac 提交于 2020-01-14 10:52 . first commit
package fuzzes
import avro "gopkg.in/avro.v0"
const ComplexSchemaRaw = `{
"type": "record",
"namespace": "example.avro",
"name": "Complex",
"fields": [
{
"name": "stringArray",
"type": {
"type": "array",
"items": "string"
}
},
{
"name": "longArray",
"type": {
"type": "array",
"items": "long"
}
},
{
"name": "enumField",
"type": {
"type": "enum",
"name": "foo",
"symbols": [
"A",
"B",
"C",
"D"
]
}
},
{
"name": "mapOfInts",
"type": {
"type": "map",
"values": "int"
}
},
{
"name": "unionField",
"type": [
"null",
"string",
"boolean"
]
},
{
"name": "fixedField",
"type": {
"type": "fixed",
"size": 16,
"name": "md5"
}
},
{
"name": "recordField",
"type": ["null", {
"type": "record",
"name": "TestRecord",
"fields": [
{
"name": "longRecordField",
"type": "long"
},
{
"name": "stringRecordField",
"type": "string"
},
{
"name": "intRecordField",
"type": "int"
},
{
"name": "floatRecordField",
"type": "float"
}
]
}]
},
{
"name":"mapOfRecord",
"type":{
"type": "map",
"values": "TestRecord"
}
}
]
}`
var ComplexSchema = avro.MustParseSchema(ComplexSchemaRaw)
var ComplexEnumSymbols = []string{"A", "B", "C", "D"}
func NewComplexEnumField() *avro.GenericEnum {
return avro.NewGenericEnum(ComplexEnumSymbols)
}
//complex
type Complex struct {
StringArray []string
LongArray []int64
EnumField *avro.GenericEnum
MapOfInts map[string]int32
UnionField interface{}
FixedField []byte
RecordField *TestRecord
MapOfRecord map[string]*TestRecord
}
type TestRecord struct {
LongRecordField int64
StringRecordField string
IntRecordField int32
FloatRecordField float32
}
const PrimitiveSchemaRaw = `{"type":"record","name":"Primitive","namespace":"example.avro","fields":[{"name":"booleanField","type":"boolean"},{"name":"intField","type":"int"},{"name":"longField","type":"long"},{"name":"floatField","type":"float"},{"name":"doubleField","type":"double"},{"name":"bytesField","type":"bytes"},{"name":"stringField","type":"string"},{"name":"nullField","type":"null"}]}`
type Primitive struct {
BooleanField bool
IntField int32
LongField int64
FloatField float32
DoubleField float64
BytesField []byte
StringField string
NullField interface{}
}
var CombinedSchemaRaw = `{
"type": "record",
"namespace": "example.avro",
"name": "CombinedEverything",
"fields": [
{
"name": "complex",
"type": ["null", ` + ComplexSchemaRaw + `]
},
{
"name": "primitive",
"type": ["null", ` + PrimitiveSchemaRaw + `]
}
]
}`
var CombinedSchema = avro.MustParseSchema(CombinedSchemaRaw)
type Combined struct {
Complex *Complex
Primitive *Primitive
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kabitionno/go-avro.git
git@gitee.com:kabitionno/go-avro.git
kabitionno
go-avro
go-avro
3a7c50c57552

搜索帮助

D67c1975 1850385 1daf7b77 1850385