-
Notifications
You must be signed in to change notification settings - Fork 128
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
Conflict resolution when collecting into a Map #880
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but let's wait for @jponge's review.
Codecov Report
@@ Coverage Diff @@
## main #880 +/- ##
============================================
+ Coverage 89.08% 89.35% +0.26%
- Complexity 3086 3098 +12
============================================
Files 391 391
Lines 12475 12479 +4
Branches 1589 1591 +2
============================================
+ Hits 11113 11150 +37
+ Misses 714 692 -22
+ Partials 648 637 -11
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, see my comments for improvement requests in docs + tests.
implementation/src/main/java/io/smallrye/mutiny/groups/MultiCollect.java
Show resolved
Hide resolved
implementation/src/main/java/io/smallrye/mutiny/groups/MultiCollect.java
Outdated
Show resolved
Hide resolved
💡 BTW I see that your commits get reported as "unverified" on GitHub ("No user is associated with the committer email.") Note that for authenticity purposes we require signed commits https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits |
You can’t check that it returns null but you can check that it is not null.
You can however have a test like https://github.com/smallrye/smallrye-mutiny/blob/main/implementation/src/test/java/io/smallrye/mutiny/groups/MultiDemandPacingTest.java#L137 <https://github.com/smallrye/smallrye-mutiny/blob/main/implementation/src/test/java/io/smallrye/mutiny/groups/MultiDemandPacingTest.java#L137> to ensure that when the function returns null then the Multi fails nicely rather than having a NPE pop up from somewhere else and leaving the subscription in an inconsistent state.
… On 21 Mar 2022, at 10:15, Mauro de Palma ***@***.***> wrote:
@indalaterre commented on this pull request.
In implementation/src/main/java/io/smallrye/mutiny/groups/MultiCollect.java <#880 (comment)>:
> @@ -164,6 +165,28 @@ public MultiCollect(Multi<T> upstream) {
return collector(upstream, Collectors.toMap(actualKM, actualVM), false);
}
+ /**
+ *
+ * @param keyMapper a ***@***.*** Function} to map item to a key for the ***@***.*** Map}. Must not be ***@***.*** null},
+ * must not produce ***@***.*** null}
+ * @param valueMapper a ***@***.*** Function} to map item to a value for the ***@***.*** Map}. Must not be ***@***.*** null},
+ * must not produce ***@***.*** null}
+ * @param mergeFunction a ***@***.*** BinaryOperator} used to resolve collisions between values associated with the same key
Ok the mergefunction must not be null. But how I can check that it doesn't return null. We can just put a comment in the documentation which says that the key will be removed in this case
—
Reply to this email directly, view it on GitHub <#880 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAGK2PYN47QKZVOVYMADXLVBA44RANCNFSM5RFIQQNA>.
You are receiving this because you were mentioned.
|
Ok just pushed the code and the commits are signed with a GPG key |
Thanks but the commits still show as unverified (email is missing, etc) :-) Also, could you add a test for the case when the function returns |
Added a test that checks the removal of the key in case of mergeFunction returns null |
Signed-off-by: mauroantonio.depalma <[email protected]>
Signed-off-by: mauroantonio.depalma <[email protected]>
I'll have to do a manual merge because it looks a weird on my side |
Manual merge of #880 Signed-off-by: Julien Ponge <[email protected]>
Merged manually in |
Hi all
this PR is just to add the mergeFunction supported by Java Map collector for streams.
This happen in case a collect to a non multimap is requested.
@jponge If you agree to this it would be possible to have this in the 2.8CR of quarkus?