Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

#

Issue

Notes 

Decision

1Add or Delete leaves (optional leaves) handle as UPDATE or ADD/DELETE ?

The delta report proposed follows the Json Patch format of representing the differences between 2 json. Going by the general convention, referring RFC-6902:

  • Add: If the target location in the source document specifies an object member that does not already exist, and a new member is added to the object, then its an add operation
  • Remove: if the target location in the source document already had a member and the member was removed from the target document then its remove operation
  • Replace/Update: If the target location specifies an object member that does exist, and that member's value is replaced, then its a replace operation
  • Here target location is equivalent to the path of particular leaf
  • So, there it should be Add/Delete.
  • Discussed in detail below
Add/Delete as per notes on the left
2How to handle multiple changes at different levels?
Example: 
  • if you compare multiple levels and say a grandchild of a the node you are comparing has been added or deleted is that an UPDATE  or just a ADD/DELETE at that level

There could be Many more complex scenarios....

Replied below


3More scenarios need to be explored and documented in detail. Such as handling arrays within a json, handling child/grandchild changes.

CPS Delta feature Exceptions

...

Anchor
discussion
discussion
Additional Details

Format/Conventions to be used for Delta Report

...

There are several ways of representing the differences between JSON but here we discuss the JSON Patch format of representing these differences because the proposed Delta report closely represents JSON patch with a few differences. This approach focuses in producing another JSON document that represents the differences between the two JSON's that have been compared.

...

Code Block
titleSample JSON Patch
collapsetrue
[
     { "op": "test", "path": "/a/b/c", "value": "foo" },
     { "op": "remove", "path": "/a/b/c" },
     { "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] },
     { "op": "replace", "path": "/a/b/c", "value": 42 },
     { "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
     { "op": "copy", "from": "/a/b/d", "path": "/a/b/e" }
   ]

...

Let's assume we have a data node having some leaf data, and this particular node happens to have multiple child nodes as well.

Now we have two basic scenarios here:

  • Add/Delete/Update of leaves
  • Add/Delete/Update of child nodes

Add/Delete/Update of leaves

if the leaves of a particular data node, having a unique xpath, are added/deleted/updated then it will be considered as an Update of the particular Data Node.

Add/Delete/Update of child/grandchild nodes

Now in this scenario we assume that a child/grandchild data node, having its unique xpath, has been added/deleted/updated. Then this operation should be considered as an addition/deletion/update of the particular child/grandchild data node at its particular level, rather than an update of parent node,

...

Proposed Algorithm

The JSON data stored in CPS can be retrieved as Maps, And using this we can find the delta between two anchors retrieved as two separate Maps. The result can be stored in an JSON array with appropriate notations for action, xpath and payload. The following algorithm can be used to find the difference between the two maps and also recursively finds the difference between the child data nodes. The response is in form of a JSON Array which closely represents the JSON Patch format as described above.

...