Skip to content

"Map" has no special support #12

Description

@kamahen

"Map" has no special support. You can do "map" fields, but it's a bit klunky; instead of something like this:

'.MapMessage'{number_ints: _{one:1, two:2}}

you need to do

'.MapMessage'{number_ints:[
    '.MapMessage.NumberIntsEntry'{key:"two",value:2},
    '.MapMessage.NumberIntsEntry'{key:"one",value:1}]}

There are a few reasons for not supporting "map" right now. The biggest one is: what representation should be done for the map?

  • dict
  • library(pairs) - key-value list
  • library(assoc)
  • library(rbtrees)
  • others?

"Dict" only allows atoms and integers for the keys (and the current library(protobufs) code doesn't convert between atoms and string). The other choices have different APIs and performance characteristics. Also, library(pairs) raises the question of ordering and whether it's significant.

For the short term, the best solution is probably a "helper" predicate that translates between the various representations and the protobuf "map". This shouldn't be difficult to write, but I don't feel like doing it until it's actually needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions