erlang#u Protobuff不';对于具有重复字段的消息,不能按预期进行解码
我正在从事一个项目,该项目使用google proto缓冲区进行内部数据交换。它的工作原理与广告中的一样好,但是对于包含重复字段的消息,它的工作原理与预期不同。以下是一个例子: 示例erlang#u Protobuff不';对于具有重复字段的消息,不能按预期进行解码,erlang,protocol-buffers,Erlang,Protocol Buffers,我正在从事一个项目,该项目使用google proto缓冲区进行内部数据交换。它的工作原理与广告中的一样好,但是对于包含重复字段的消息,它的工作原理与预期不同。以下是一个例子: 示例test.proto文件: message Test { optional string t = 1; } message Tests { repeated Test testsList = 1; } 生成erlang代码: 1> protobuffs_compile:scan_file("
test.proto
文件:
message Test {
optional string t = 1;
}
message Tests {
repeated Test testsList = 1;
}
生成erlang代码:
1> protobuffs_compile:scan_file("test.proto").
=INFO REPORT==== 14-Sep-2012::16:38:25 ===
Writing header file to "test_pb.hrl"
=INFO REPORT==== 14-Sep-2012::16:38:25 ===
Writing beam file to "test_pb.beam"
ok
生成的测试\u pb.hrl
:
-ifndef(TEST_PB_H).
-define(TEST_PB_H, true).
-record(test, {
t
}).
-endif.
-ifndef(TESTS_PB_H).
-define(TESTS_PB_H, true).
-record(tests, {
testslist = []
}).
-endif.
编码:
5> test_pb:encode_tests({tests, [{test, <<"t">>}]}).
<<10,3,10,1,116>>
只是为了更新一下
0.7.0
、0.6.0
和HEAD
都给了我上述相同的问题
在讨论了#riak IRC之后,我意识到我们需要使用这个提交哈希标记的稳定版本:E0F5F6EA4C3DCB4E7B824496D2B4833FBD5A8C8
,它解决了上述问题。只是为了更新
0.7.0
、0.6.0
和HEAD
都给了我上述相同的问题
在讨论了#riak IRC之后,我意识到我们需要使用这个提交哈希标记的稳定版本:
e0f5f6ea4c3dcb4e7b824496d2b4833fbd5a8c8
,它解决了上述问题。只是为了更新阅读本文的用户,Basho的人已经修复了它。所以现在就可以使用master了:只是为了更新阅读本文的用户,Basho的人已经修复了它。所以现在就可以使用master了:
6> test_pb:decode_tests(<<10,3,10,1,116>>).
{[{test,"t"}],undefined}
{tests, [{test, <<"t">>}]}
{protobuffs, "0.7.0", {git, "git://github.com/basho/erlang_protobuffs.git", {tag, "0.7.0"}}}