Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Protocol buffers 将Protobuf定义转换为节俭_Protocol Buffers_Thrift - Fatal编程技术网

Protocol buffers 将Protobuf定义转换为节俭

Protocol buffers 将Protobuf定义转换为节俭,protocol-buffers,thrift,Protocol Buffers,Thrift,是否有任何工具可以从Protobuf定义生成Thrift接口定义?答案似乎是“还没有”。您将面临的一个问题是thrift使用服务和方法调用定义了一个完整的RPC系统,而protobuf真正关注的是数据类型和序列化位。Thrift的数据模型比protobuf的(无递归结构等)有一点限制,但这在Thrift->protobuf方向上不应该是一个问题 当然,您可以非常轻松地将所有thrift数据类型转换为protobuf定义,同时完全忽略服务部分。如果愿意,您甚至可以在thrift编译器中添加类似的内

是否有任何工具可以从Protobuf定义生成Thrift接口定义?

答案似乎是“还没有”。您将面临的一个问题是thrift使用服务和方法调用定义了一个完整的RPC系统,而protobuf真正关注的是数据类型和序列化位。Thrift的数据模型比protobuf的(无递归结构等)有一点限制,但这在Thrift->protobuf方向上不应该是一个问题

当然,您可以非常轻松地将所有thrift数据类型转换为protobuf定义,同时完全忽略服务部分。如果愿意,您甚至可以在thrift编译器中添加类似的内置生成器


不过,节俭和普罗托夫是不能互换的。看一看,看看一些关键的区别。你到底想做什么?

我想没有。如果你能为此编写代码,你可以编写一个语言生成器,为你生成.thrift文件

可以用任何语言编写工具(C++中在原Buff-J2ME(1)中编写的,以及在[2 ]中修改的OpthBuff-cSpice端口代码)。 您可以使用protoc.exe对其进行如下调用:

protoc.exe --plugin=protoc-gen-thrift.exe --thrift_out=. file.proto
您需要将其命名为
protoc gen thrift.exe
,以使
--thrift\u out
选项可用

[1]

[2] I将节俭的子集转换为Protobuf,反之亦然

这是一些节俭代码:

enum Operation{
    ADD=1,SUBTRACT=2,MULTIPLY=3,DIVIDE=4
}
struct Work{1:i32 num1,2:i32 num2,4:string comment
}
将自动转换为此Protobuf代码:

enum Operation{
    ADD=1,SUBTRACT=2,MULTIPLY=3,DIVIDE=4
}
message Work{int32 num1 = 1;int32 num2 = 2;string comment = 4;
}