Repository navigation
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR fixes WindmillMapViaMultimap.computeIfAbsent to conform to the MapState contract by returning null upon inserting a computed value and by treating keys mapped to null as absent. It also adds unit test coverage in WindmillMapViaMultimapTest.
🔍 General Feedback
- The logic in
computeIfAbsentis sound and properly replaces existingnullentries viaput(key, inserted). - There is an unused import in the new test file that will likely trigger Checkstyle/Spotless failures in CI, as well as a couple of minor cleanups in
WindmillMapViaMultimapandWindmillMapViaMultimapTest.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #40750 +/- ##
=============================================
+ Coverage 56.16% 75.97% +19.80%
+ Complexity 2288 2273 -15
=============================================
Files 1124 259 -865
Lines 178336 14377 -163959
Branches 1489 1479 -10
=============================================
- Hits 100170 10923 -89247
+ Misses 75645 2763 -72882
+ Partials 2521 691 -1830
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bb94c36 to
1669ffd
Compare
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR fixes WindmillMapViaMultimap.computeIfAbsent to align with the MapState contract by returning ReadableStates.immediate(null) upon inserting a computed value and handling keys mapped to null. It also introduces a comprehensive unit test suite in WindmillMapViaMultimapTest covering core map operations and edge cases, with all previous review feedback addressed.
🔍 General Feedback
- The implementation in
WindmillMapViaMultimapis clean, avoids redundant iterator creation, and properly overwritesnull-mapped keys viaput(key, inserted). - The unit test coverage in
WindmillMapViaMultimapTestthoroughly validates the contract fixes and standardMapStateoperations.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @damccorm added as fallback since no labels match configuration Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
R: @scwhittle |
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
|
I find it pretty confusing that MapState.computeIfAbsent doesn't match Java Map.computeIfAbsent behavior where it returns the existing or newly computed value. https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#computeIfAbsent-K-java.util.function.Function- I think it would be better to update the comment and match Map. Especially if the existing implementations are already behaving the other way. |
Conforms to Beam's MapState.computeIfAbsent contract by returning ReadableStates.immediate(null) when a key was absent and a computed value is inserted.
Added support for keys mapped to null: computes and updates when existing == null per the MapState contract ("or is mapped to null").
Added new unit tests to demonstrate these bugs and added some basic unit tests since none previously existed.