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

Add support for WRITE_SORTED_MAP_ENTRIES for Guava Multimaps #7

Closed
cowtowncoder opened this issue May 19, 2016 · 4 comments · Fixed by #109
Closed

Add support for WRITE_SORTED_MAP_ENTRIES for Guava Multimaps #7

cowtowncoder opened this issue May 19, 2016 · 4 comments · Fixed by #109
Labels
2.15 good first issue Issue that seems easy to resolve and is likely a good candidate for contributors new to project guava

Comments

@cowtowncoder
Copy link
Member

Currently (2.7.5) MultimapSerializer does not make use of either SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS or JsonFormat.Feature.WRITE_SORTED_MAP_ENTRIES; it should.

@cowtowncoder cowtowncoder added 2.12 and removed 2.9 labels Jun 9, 2020
@cowtowncoder cowtowncoder added the good first issue Issue that seems easy to resolve and is likely a good candidate for contributors new to project label Oct 16, 2020
@sukhrajm
Copy link

Hi, I was going to take a look at this as my first time contributing. I think i can re-create this as a failing test by creating a HashMultimap and inserting keys such as key-0, key-1, key-2. Then i configure the objectmapper with SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true. Then on serialization, the json should maintain the keys natural ordering but it doesn't currently.

@cowtowncoder
Copy link
Member Author

That sounds good. Alternatively if there is insertion-order-retaining variant, that might be best for repeatable test case; although if hash order is stable enough that should work.

@sukhrajm
Copy link

sukhrajm commented Oct 29, 2020

There is a comment where this should be plugged in MultimapSerializer. I was thinking of doing
ImmutableSetMultimap<?, ? extends Collection<?>> immutableSortedMultimap = ImmutableSortedMap.copyOf(value.asMap()).asMultimap();

Where value is passed in is a HashMultimap - the map is a String -> HashSet

after the sorting immutableSortedMultimap has a wrapped structure. the value is a SingletonImmutableSet with the value being a set of a set. And the _valueSerializer is set to StringCollectionSerializer Perhaps this is the wrong strategy to tackle this problem?

@cowtowncoder
Copy link
Member Author

I haven't looked into this, and do not remember how Guava Multimaps work. Maybe someone else can help here.

@cowtowncoder cowtowncoder changed the title [guava] Add support for WRITE_SORTED_MAP_ENTRIES Add support for WRITE_SORTED_MAP_ENTRIES for Guava Multimaps Mar 20, 2023
@cowtowncoder cowtowncoder added 2.15 and removed 2.12 labels Mar 20, 2023
cowtowncoder added a commit that referenced this issue Mar 21, 2023
cowtowncoder added a commit that referenced this issue Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.15 good first issue Issue that seems easy to resolve and is likely a good candidate for contributors new to project guava
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants