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

Fixes GitHub issue #30257 #32074

Merged
merged 1 commit into from
Aug 14, 2024
Merged

Fixes GitHub issue #30257 #32074

merged 1 commit into from
Aug 14, 2024

Conversation

kirupha2000
Copy link
Contributor

@kirupha2000 kirupha2000 commented Aug 4, 2024

Fixes #30257

Adds a static comparing method to the SerializableComparator interface. This almost similar to the inbuilt Java's Comparator#comparing(Function) method except that it uses SerializableFunction.

Copy link

codecov bot commented Aug 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.66%. Comparing base (bf42a81) to head (a89b7b9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #32074      +/-   ##
============================================
+ Coverage     57.18%   58.66%   +1.48%     
- Complexity     1474     3023    +1549     
============================================
  Files           963     1121     +158     
  Lines        152697   172724   +20027     
  Branches       1076     3275    +2199     
============================================
+ Hits          87313   101336   +14023     
- Misses        63202    68084    +4882     
- Partials       2182     3304    +1122     
Flag Coverage Δ
java 69.60% <ø> (+1.03%) ⬆️

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

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

Copy link
Contributor

github-actions bot commented Aug 4, 2024

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@je-ik
Copy link
Contributor

je-ik commented Aug 4, 2024

R: @je-ik

@je-ik je-ik self-requested a review August 4, 2024 08:13
Copy link
Contributor

github-actions bot commented Aug 4, 2024

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

@kirupha2000
Copy link
Contributor Author

Hi @je-ik , it took a while for me to figure out that there were some check style errors in the code😅. I've fixed those but looks like there are some checks failing that passed in the previous commit. Can you please guide me here if it's anything that I should fix on my end? Thanks!

@je-ik
Copy link
Contributor

je-ik commented Aug 9, 2024

Hi @kirupha2000 , I'm sorry, I'm OOO, currently. I will take a look at this next week. Thanks for the contribution!

Copy link
Contributor

@je-ik je-ik left a comment

Choose a reason for hiding this comment

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

LGTM, I'd only suggest to test the serializable part of the contract of the created comparator.

@je-ik
Copy link
Contributor

je-ik commented Aug 12, 2024

Also please squash the change to single commit. There is a documentation about how to structure granularity of commits in https://github.com/apache/beam/blob/master/contributor-docs/committer-guide.md. Thanks!

Copy link
Contributor

@je-ik je-ik left a comment

Choose a reason for hiding this comment

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

Added a few more comments.

SerializableFunction<String, Integer> fn = Integer::parseInt;

SerializableComparator<String> cmp = SerializableComparator.comparing(fn);
Assert.assertTrue(cmp instanceof Serializable);
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not imply that the instance can be serialized. It would be better to use the SerializableUtils to check the serialization and deserialization.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could have left the original tests as well, those were fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be sufficient to check if the returned Comparator is serializable using org.apache.beam.sdk.util.SerializableUtils#ensureSerializable(T) or should we check using something else?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that is exactly the method to use. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-added the original tests and used org.apache.beam.sdk.util.SerializableUtils#ensureSerializable(T).

Adds a static comparing method to the SerializableComparator interface
Copy link
Contributor

@je-ik je-ik left a comment

Choose a reason for hiding this comment

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

LGTM, I will merge after tests pass. Thanks for the contribution!

@je-ik je-ik merged commit 7a4850d into apache:master Aug 14, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: [beam-sdks-java-core]: Create method SerializableComparator.comparing(SerialiableFunction)
2 participants