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

bulk ops deserialization #2686

Conversation

ElizabethOkerio
Copy link
Contributor

@ElizabethOkerio ElizabethOkerio commented Jul 14, 2022

Issues

Description

This pull request is a sub of this big PR #2656. We have broken the big PR into 3PRs - deserialization/serialization/ApiHandlers to hasten the review. This PR contains only deserialization changes for bulk operations.

N/B: This PR seems big but it is not really big, most of the changes are minor changes - like removing or adding whitespace where needed.
A sample delta payload will look like below:

{
  "@odata.context": "http://host/service/$metadata#Customers/$delta",
  "value": [
    {
      "Id": 1,
      "Name": "Customer1",
      "[email protected]": [
        {
          "Id": 1,
          "Street": "123 Street",
          "City": "Redmond"
        },
        {
          "Id": 2,
          "Street": "234 Street",
          "City": "Seattle"
        }
      ]
    },
    {
      "Id": 2,
      "Name": "Customer2",
      "[email protected]": [
        {
          "@odata.removed": {
            "reason": "removed"
          },
          "Id": 1
        },
        {
          "Id": 12,
          "Street": "434 Street",
          "City": "Seattle"
        }
      ]
    }
  ]
}

some of the main changes are:
We have added the following classes and interfaces to assist in the deserialization of delta payloads- like the one shown above.:

  1. IDeltaSetItem - A basic interface representing a delta item.
  2. IDeltaSet - A basic delta representing a deltaset - collection of deltas
  3. IDeltaDeletedEntityObject - Represents a typed deleted entity object.
  4. IODataIdContainer - An interface to hold ODataId -@odata.id - in parsed format. Used by both POCO objects and Delta
  5. ODataResourceSetWrapperBase - Encapsulates an ODataResourceSet or ODataDeltaResourceSet
  6. DeltaSet - Represents an IDeltaSet that is a collection of IDeltaSetItem.
  7. DeltaDeletedEntityObject - Used to hold the Deleted Entry object in the Delta Feed Payload.

Changes have also been made to the ODataReaderExtensions - we check for the readerstate - if there is a deltaresourcesetstart state, we'll create an odatadeltaresourceset.
Changes have also been made to the ODataResourceSetDeserializer and ODataResourceDeserializer to handle creating a deltaset from a delta request payload.

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Build and test with one-click build and test script passed

Additional work necessary

If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.

Copy link
Contributor

@habbes habbes left a comment

Choose a reason for hiding this comment

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

Left some comments, suggestions and a few things that looked like potential bugs.

The PR seems to introduce potentially breaking changes, is it meant for 7.x?

There seems to be a lot of changes made to existing tests that I didn't quite understand, which lowered my confidence in figuring out whether the PR doesn't break things.

@ElizabethOkerio
Copy link
Contributor Author

Left some comments, suggestions and a few things that looked like potential bugs.

The PR seems to introduce potentially breaking changes, is it meant for 7.x?

There seems to be a lot of changes made to existing tests that I didn't quite understand, which lowered my confidence in figuring out whether the PR doesn't break things.

@habbes the main reason there are some changes to the tests is because there is some logic that didn't work as expected before. The logic was changed and now works correctly hence the reason why some tests were removed completely or changes made to them.

@ElizabethOkerio ElizabethOkerio force-pushed the feature/update_bulk_ops_deserialization branch 3 times, most recently from 2c5617b to 829e5d7 Compare July 27, 2022 12:27
@ElizabethOkerio ElizabethOkerio force-pushed the feature/update_bulk_ops_deserialization branch 2 times, most recently from eaf46cc to e7cad64 Compare August 3, 2022 11:23
@ElizabethOkerio ElizabethOkerio force-pushed the feature/update_bulk_ops_deserialization branch from c9dfae8 to a06c376 Compare September 1, 2022 09:57
@ElizabethOkerio ElizabethOkerio force-pushed the feature/update_bulk_ops_deserialization branch from b1726e8 to f3a8ab7 Compare September 2, 2022 08:38
KenitoInc
KenitoInc previously approved these changes Sep 5, 2022
Copy link
Contributor

@KenitoInc KenitoInc left a comment

Choose a reason for hiding this comment

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

LGTM

if (TypeHelper.HasDefaultConstructor(newType))
{
newOriginalNestedResource = Activator.CreateInstance(newType);
}
Copy link
Contributor

@gathogojr gathogojr Sep 8, 2022

Choose a reason for hiding this comment

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

I believe we should throw an exception if the type has no default constructor. Otherwise return a null will result into a NullReferenceException when we later call CopyChangedValues. Would actually be better if you handled that scenario and added a test to confirm that an exception is thrown

xuzhg
xuzhg previously approved these changes Sep 8, 2022
@ElizabethOkerio ElizabethOkerio force-pushed the feature/update_bulk_ops_deserialization branch from e78a146 to 8176c82 Compare September 9, 2022 12:23
gathogojr
gathogojr previously approved these changes Sep 9, 2022
Copy link
Contributor

@gathogojr gathogojr left a comment

Choose a reason for hiding this comment

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

I'm still a bit worried about the ODataResourceDeserializerHelpers class. The logic in some of those methods look/feel brittle and complex to me, starting with the ApplyIdPath method. I just hope you have validated as much logic as possible in that class

@pull-request-quantifier-deprecated

This PR has 1831 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Extra Large
Size       : +1421 -410
Percentile : 100%

Total files changed: 63

Change summary by file extension:
.cs : +1183 -391
.resx : +18 -0
.projitems : +13 -0
.csproj : +6 -1
.bsl : +201 -18

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detected.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@ElizabethOkerio ElizabethOkerio merged commit cda7e83 into OData:master Sep 12, 2022
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.

5 participants