Skip to content

Fixes some bugs in WindmillMapViaMultimap. - #40750

Open
acrites wants to merge 3 commits into
apache:masterfrom
acrites:windmill-map-via-multimap-fix
Open

acrites wants to merge 3 commits into
apache:masterfrom
acrites:windmill-map-via-multimap-fix

Conversation

@acrites

@acrites acrites commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 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 computeIfAbsent is sound and properly replaces existing null entries via put(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 WindmillMapViaMultimap and WindmillMapViaMultimapTest.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions github-actions Bot added runners dataflow size/m M: 50-249 lines changed labels Oct 23, 2026
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.97%. Comparing base (76f6e6d) to head (1669ffd).
⚠️ Report is 310 commits behind head on master.

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     
Flag Coverage Δ
go ?
java 75.97% <ø> (+0.18%) ⬆️
python ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@acrites
acrites force-pushed the windmill-map-via-multimap-fix branch from bb94c36 to 1669ffd Compare October 23, 2026 17:55
@acrites

acrites commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 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 WindmillMapViaMultimap is clean, avoids redundant iterator creation, and properly overwrites null-mapped keys via put(key, inserted).
  • The unit test coverage in WindmillMapViaMultimapTest thoroughly validates the contract fixes and standard MapState operations.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @damccorm added as fallback since no labels match configuration
Backup reviewer: tvalentyn (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@damccorm

Copy link
Copy Markdown
Contributor

R: @scwhittle

@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@scwhittle

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants