我正在尝试使用avro-tools将avro avdl文件(http://avro.apache.org/docs/1.7.6/idl.html#example)转换为avro架构文件(example.avsc)。 我下载了avro-tools 1.7.6和1.6.3
example.avdl
/**
* An example protocol in Avro IDL
*/
@namespace("org.apache.avro.test")
protocol Simple {
@aliases(["org.foo.KindOf"])
enum Kind {
FOO,
BAR, // the bar enum value
BAZ
}
fixed MD5(16);
record TestRecord {
@order("ignore")
string name;
@order("descending")
Kind kind;
MD5 hash;
union { MD5, null} @aliases(["hash"]) nullableHash;
array<long> arrayOfLongs;
}
error TestError {
string message;
}
string hello(string greeting);
TestRecord echo(TestRecord `record`);
int add(int arg1, int arg2);
bytes echoBytes(bytes data);
void `error`() throws TestError;
void ping() oneway;
}
生成example.avsc
{
"protocol" : "Simple",
"namespace" : "org.apache.avro.test",
"doc" : "* An example protocol in Avro IDL",
"types" : [ {
"type" : "enum",
"name" : "Kind",
"symbols" : [ "FOO", "BAR", "BAZ" ],
"order" : "descending",
"aliases" : [ "org.foo.KindOf" ]
}, {
"type" : "fixed",
"name" : "MD5",
"size" : 16
}, {
"type" : "record",
"name" : "TestRecord",
"fields" : [ {
"name" : "name",
"type" : {
"type" : "string",
"order" : "ignore"
}
}, {
"name" : "kind",
"type" : "Kind"
}, {
"name" : "hash" ...
我在我的mac上使用以下命令来生成它
java -jar avro-tools-1.6.3.jar idl example.avdl (我已尝试过1.6.3和1.7.6)
上面生成的模式文件无效,因为它没有名称,类型和字段作为顶级属性。
这里有什么不对吗?
由于