/
Delta Report for Bulk Operations

Delta Report for Bulk Operations

Issues/Decision Table

Date

Item

Owner

Notes

Relevant Links

Date

Item

Owner

Notes

Relevant Links

Aug 9, 2024

 

@someone

Action

 

Introduction

The goal of Delta feature in CPS was to have the ability to generate a difference between two configurations stored in the database and then use the Delta Report in multiple scenarios. One of these being to use the delta report to perform bulk operations like, create, delete update and replace data.

The basic idea is to use the entries in the delta report and execute the aforementioned operations using the CPS core APIs. But in doing so there are a few challenges that are discussed in this document.

Delta Report to add new data using CPS Core Create Node API

The idea is to use the CPS Core Create node API to add new data nodes under existing data nodes. The new data nodes will be fetched from the delta report identified by the “create” operation, then using the parent-node xpath and the target data as the xpath and payload for the create node API respectively. But the problem here is that the Create a Node API does not allow adding new data nodes when some data already exists under an anchor.

Proposed Solutions

  • Add support to add new data nodes using Create node API

  • Alternatively update node API can be used for the same but currently the Update node API allows only updating leaves of a data node already present in the database.

  • Add a new endpoint to perform bulk operations using delta report.

Delta Report to remove data using CPS Core Delete a Node API

For bulk delete operations entries under the “remove” operation of delta report would be used to get the data to be deleted. But the problem with this approach is that the Delete node API in CPS core does not accept a payload. It only accepts a xpath as query parameter and deletes any data under the xpath.

So, if the parent-node xpath is fetched from the delta report all the data under the particular xpath will be deleted.

For example, if we have nodes B1,B2, B3 and B4 under parent node A and the delta report reports that data node B2 and B3 under parent-node xpath /A have been removed. If only the parent node xpath is used from the delta report, then the Delete a node API would delete nodes B1 and B4 as well.

Node A └── Node B1 └── Node B2 └── Node B3 └── Node B4
[ { "action": "remove", "xpath": "/nodes/Node A", "sourceData": [ { "Node": "B2" }, { "Node": "B3" } } ] } ]
DELETE: /cps/api/v2/dataspaces/my-dataspace/anchors/test-anchor/nodes?xpath=%2FA'

Proposed solutions

  • Modify the delete node API to accept a payload to delete specific data nodes under a parent node xpath.

  • Add a new endpoint to perform bulk operations using delta report.

Delta Report to update data using CPS Core API

The delta feature reports the updated nodes differently when compared to added and removed data nodes.

The updated entries in delta report contain information about one node and it only reports the leaves of the data nodes that have been updated.

This information cannot be used directly with the Update a node API because the Update node API accepts parent-node xpath and the payload contains the entire node information, i.e. the node name and the updated leaves.

For example, if leaf 2 is updated under Node-A containing leaf 1 and 2 then the delta report would be as follows:

And the update request will be as follows:

Proposed Solutions

  • Modify the update a node API to accept exact node xpath along with the leaves to be updated provided as part of the payload (this would not include the node name).

  • Modify the delta report to reconstruct the data node with updated leaves so that it contains node name and leaves in the delta report.

  • Add a new endpoint to perform bulk operations using delta report.

 

 

 

Related content