用户定义类型的 Avro 默认值
Avro default value for user defined types
是否可以为用户定义的类型设置默认值?
即给定 avdl:
protocol {
record A { }
record B {
union { A, string } foo = A;
}
}
记录 B 有效并且 thing
默认情况下是 A 的实例?
找到答案,{}
idl:
protocol {
record A { }
record B {
union { A, string } foo = {};
}
}
avsc 中的结果:
{
"type" : "record",
"name" : "B",
"fields" : [ {
"name" : "foo",
"type" : [ {
"type" : "record",
"name" : "A",
"fields" : [ ]
}, "string" ],
"default" : { }
} ]
}
这意味着:new
第一种联合类型,在本例中为 A.
是否可以为用户定义的类型设置默认值?
即给定 avdl:
protocol {
record A { }
record B {
union { A, string } foo = A;
}
}
记录 B 有效并且 thing
默认情况下是 A 的实例?
找到答案,{}
idl:
protocol {
record A { }
record B {
union { A, string } foo = {};
}
}
avsc 中的结果:
{
"type" : "record",
"name" : "B",
"fields" : [ {
"name" : "foo",
"type" : [ {
"type" : "record",
"name" : "A",
"fields" : [ ]
}, "string" ],
"default" : { }
} ]
}
这意味着:new
第一种联合类型,在本例中为 A.