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

perf: Use and re-use ObjectWriter for data serialization (fixes #1381) #1382

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dhardtke
Copy link
Contributor

@dhardtke dhardtke commented Feb 6, 2021

Also moves the configuration of ComponentData's serializer inside ComponentDataImpl

Q                       A
Fixed Issues? Fixes #1381
Patch: Bug Fix? No
Minor: New Feature? Maybe
Major: Breaking Change? No
Tests Added + Pass? No new tests necessary
Documentation Provided Yes (code comments and or markdown)
Any Dependency Changes?
License Apache License, Version 2.0

Copy link
Contributor

@ky940819 ky940819 left a comment

Choose a reason for hiding this comment

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

This PR should probably be made against adobe:development and not adobe:master.

* @since com.adobe.cq.wcm.core.components.models 12.12.0
*/
@Nullable
@JsonProperty("dataLayer")
@JsonSerialize(using = ComponentDataModelSerializer.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

The removal of this line breaks the serialization of the data model.
The serialized format should be along the lines of:

{
    "<ComponentID>": {
        "....serialized ComponentData..."
    }
}

The results of this change cause

{
    "....serialized ComponentData..."
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Here's a diff of actual test output (expected on left, actual on right).
Please make sure to run the tests.

Screenshot from 2021-02-06 03-27-23

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR should probably be made against adobe:development and not adobe:master.

Thanks, I changed the base of this PR.

The removal of this line breaks the serialization of the data model.
Yes, it did. The change was intentional, though. As I mentioned in the PR's description it's probably not a good idea to reference the serializer (which is located inside "internal") from within the public API.

As far as I can tell the serializer is only necessary to be used inside Unit tests, correct? Are consumers of the API expecting to be able to serialize instances of Component directly which in turn should use the Serializer? Or are consumers only supposed to call ComponentData#getJson?

(This might be a concern especially when using ComponentExporter)

Copy link
Member

Choose a reason for hiding this comment

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

Component/ContainerExporter serialization is important for SPA developers (which consume .model.json output instead of rendered HTML attributes to feed the DataLayer).

@dhardtke dhardtke changed the base branch from master to development February 6, 2021 15:58
@dhardtke dhardtke closed this Feb 6, 2021
@dhardtke dhardtke force-pushed the perf/1381-use-re-usable-objectwriter branch from 65a542f to 2bd4fcf Compare February 6, 2021 16:45
…#1381)

Also moves the configuration of ComponentData's serializer inside ComponentDataImpl
@dhardtke dhardtke reopened this Feb 6, 2021
@sonarcloud
Copy link

sonarcloud bot commented Feb 6, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
1.3% 1.3% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Jul 8, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link

sonarcloud bot commented Dec 27, 2023

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

codecov bot commented Dec 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ca953b4) 87.34% compared to head (cf1ea6c) 87.34%.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1382   +/-   ##
=========================================
  Coverage     87.34%   87.34%           
  Complexity     2648     2648           
=========================================
  Files           232      232           
  Lines          7080     7081    +1     
  Branches       1073     1073           
=========================================
+ Hits           6184     6185    +1     
  Misses          359      359           
  Partials        537      537           

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Component#getData performance by re-using ObjectMapper
3 participants