Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maps containing maps are returned as arrays and not map objects [JIRA: CLIENTS-1025] #328

Open
mikrofusion opened this issue Nov 10, 2016 · 1 comment

Comments

@mikrofusion
Copy link

When fetching a map containing another map (lets call this sub_map), the sub_map is returned as an array and not as a map object. I would expect that the sub_map would be of the map type so that map methods can be used on it (such as riakc_map:fetch_keys(Map) )

Code

Note: I am using the riak-erlang-client in elixir, hence the elixir syntax.

Example of creating the map:

       map = :riakc_map.new()

        map = :riakc_map.update({"map", :map}, fn(s) ->
          :riakc_map.update({"map", :map}, fn(c) ->
            c = :riakc_map.update({"set", :set},
              fn(s) -> :riakc_set.add_element("biz", s) end,
            c)
            :riakc_map.update({"flag1", :flag},
              fn(f) -> :riakc_flag.enable(f) end,
            c)
          end, s)
        end, map)

        :ok = :riakc_pb_socket.update_type(pid, {"maps", bucket}, key, :riakc_map.to_op(map))

example of fetching the map:

        {:ok, map} = :riakc_pb_socket.fetch_type(pid, {"maps", bucket}, key)
        sub_map = :riakc_map.fetch({"map", :map}, map)

at this point I would expect sub_map to be a map object which I can call fetch keys or fetch on, instead the object returned is an array, like so:

[{{"map", :map}, [{{"flag1", :flag}, true}, {{"set", :set}, ["biz"]}]}]

This seems incorrect as it seems to remove some of the value of using maps within maps, since the whole object will have to be recreated and re-updated in order to change any values.

Thanks in advance for any help you can provide.

@Basho-JIRA Basho-JIRA changed the title Maps containing maps are returned as arrays and not map objects Maps containing maps are returned as arrays and not map objects [JIRA: CLIENTS-1025] Nov 10, 2016
@lukebakken lukebakken added the Bug label Nov 10, 2016
@lukebakken lukebakken added this to the riak-erlang-client-2.5.1 milestone Nov 10, 2016
@lukebakken
Copy link
Contributor

Thanks for the report, this seems like a bug. We will investigate.

@lukebakken lukebakken modified the milestones: riak-erlang-client-2.5.1, riak-erlang-client-2.5.2 Dec 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants