You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Anthony Molinaro (JIRA)" <ji...@apache.org> on 2011/09/06 07:09:09 UTC
[jira] [Commented] (THRIFT-1321) Map serialization is broken in the
Erlang library
[ https://issues.apache.org/jira/browse/THRIFT-1321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13097743#comment-13097743 ]
Anthony Molinaro commented on THRIFT-1321:
------------------------------------------
I'm not seeing how this is a bug, I put together this to test
{noformat}
struct A { 1: map<string, string> x }
{noformat}
{noformat}
-module(test_thrift_1321).
-include("thrift1321_types.hrl").
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
broken_map_serialization_test() ->
S = #a { x = dict:from_list ([{<<"foo">>,<<"bar">>},{<<"baz">>,<<"bob">>}]) },
{ok, T0} = thrift_memory_buffer:new (),
{ok, P0} = thrift_binary_protocol:new (T0),
{P1, ok} = thrift_protocol:write (P0,
{{struct, element(2, thrift1321_types:struct_info(a))}, S}),
{_, {ok, R}} = thrift_protocol:read (P1,
{struct, element(2, thrift1321_types:struct_info(a))}, a),
?assertEqual (S, R).
-endif.
{noformat}
And the map serializes and deserializes fine. Do you have a test case of this not working? I pretty extensively use map to talk erlang to java and java to erlang so if this were a bug I would expect to have seen it before, but then again I only really use map<string,string> so maybe that case works where others fail? Anyway, if you have an example that would be best, thanks.
> Map serialization is broken in the Erlang library
> -------------------------------------------------
>
> Key: THRIFT-1321
> URL: https://issues.apache.org/jira/browse/THRIFT-1321
> Project: Thrift
> Issue Type: Bug
> Components: Erlang - Library
> Affects Versions: 0.7
> Reporter: Louis-Philippe Gauthier
> Attachments: bug.diff
>
>
> dict:fold/3 always return ValData as a list and therefore breaks the pattern matching (guards).
> {quote}
> Dict = dict:new(),
> Dict2 = dict:append("key1", "value1", Dict),
> Dict3 = dict:append("key2", [1,2,3], Dict2),
> Dict4 = dict:append("key3", <<"value3">>, Dict3),
> dict:fold(fun(Key, Value, AccIn) -> io:format("~p : ~p~n", [Key, Value]) end, [], Dict4).
> "key1" : ["value1"]
> "key2" : [[1,2,3]]
> "key3" : [<<"value3">>]
> {quote}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira