我正在尝试使用avro将avro文件( 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 tools-1.6.3.jar -jar example.avdl (我已经尝试过1.6.3和1.7.6)
上面生成的架构文件无效,因为它没有名称、类型和字段作为顶级属性。
这里有什么问题吗?
谢谢
发布于 2015-01-17 17:03:28
idl命令生成Avro文件(.avpr) -要生成模式(.avsc),您需要使用idl2schemata命令,该命令将输入idl和可选输出目录作为参数(如果不提供当前目录),并根据IDL中的类型生成一个或多个文件。
java -jar avro-tools-1.7.7.jar idl2schemata example.avdl .https://stackoverflow.com/questions/24274178
复制相似问题