【发布时间】:2014-06-17 22:14:38
【问题描述】:
我正在尝试使用 avro 工具将 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;
}
生成的例子.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我都试过了)
上述生成的架构文件无效,因为它没有名称、类型和字段作为顶级属性。
这里有什么问题吗?
谢谢
【问题讨论】:
-
"上面生成的模式文件无效,因为它没有名称、类型和字段作为顶级属性。" - 据我所知,所有属性都存在于正确的级别。 “名称”出现在 TestRecord 等等......你还期待它们在哪里?