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

Change deserialization and merge patch to bitwise #2909

Conversation

alzimmermsft
Copy link
Member

Updates JSON merge patch and fromJson code to use bitwise tracking instead of a Set<String> and a boolean per tracking instance.

Copy link
Member

@weidongxu-microsoft weidongxu-microsoft left a comment

Choose a reason for hiding this comment

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

@haolingdong-msft could you take review on this, as it is about json-merge-patch?

/**
* Set the result property: Operation result upon success.
*
* @param result the result value to set.
Copy link
Member

Choose a reason for hiding this comment

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

Is it just changing the order?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is just a change in order but it's a good time to have a discussion on how we want to order overridden methods. Before this change, the methods defined the type came first then overridden methods, but in serialization code the properties defined by super types came first. It'd be nice to have a standard system for both serialization and getters/setters, such as properties and setters/getters defined by super types always come first (or last).

Copy link
Member

Choose a reason for hiding this comment

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

To me, as long as the two orders (methods order and properties processing order during serialziation) are consistent, and both override methods and new methods have their own section, that would be fine.
I also asked copilot. It says override methods from super class comes first. So I would vote for this - override methods come first. :)
image

@@ -1339,7 +1346,7 @@ private void addJsonMergePatchRelatedPropertyAndAccessors(JavaClass classBlock,
classBlock.javadocComment(comment ->
comment.description("Stores updated model property, the value is property name, not serialized name"));
addGeneratedAnnotation(classBlock);
classBlock.privateFinalMemberVariable("Set<String> updatedProperties = new HashSet<>()");
classBlock.privateMemberVariable("long updatedProperties = 0L");
Copy link
Member

@haolingdong-msft haolingdong-msft Aug 13, 2024

Choose a reason for hiding this comment

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

Once concern from me is would bitwise make it harder to debug?
e.g. we found the serialization content is wrong, and we want to see if the updated properties are expected.

Copy link
Member Author

Choose a reason for hiding this comment

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

It would make debugging moderately more difficult; it'd be a change from checking updatedProperties.contains(string) to doing a bitwise operation that matches the logic used by the setter. In both cases you'll still need to look at the setter or serialization code to see what's going on.

Copy link
Member

@weidongxu-microsoft weidongxu-microsoft Aug 14, 2024

Choose a reason for hiding this comment

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

Emm.. what if the model has more than 64 properties (it is unlikely but not impossible)? java.util.BitSet?

@microsoft-github-policy-service microsoft-github-policy-service bot added the no-recent-activity There has been no recent activity on this issue. label Oct 25, 2024
Copy link
Contributor

Hi @alzimmermsft. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

Copy link
Contributor

Hi @alzimmermsft. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing "/reopen" if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the "no-recent-activity" label; otherwise, this is likely to be closed again with the next cleanup pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-recent-activity There has been no recent activity on this issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants