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

Update value linked relationship to support parent side auto connect #1125

Merged
merged 18 commits into from
Dec 11, 2021

Conversation

chuan
Copy link
Contributor

@chuan chuan commented Dec 8, 2021

This change completes value linked relationship with parent side auto connection support. The reference chain structures are updated to support efficient connection and disconnection on both sides of a relationship. We added a middle node (called anchor node) between child linked list and their parent node. We also added a back link to each child node. This allows us to efficiently connect/disconnect parent node to a list of child nodes, as well as efficiently remove a single child from the list.

Previous manual connection methods like connect, disconnect, insert, and erase are not available on the new reference chain as intended. I disabled some tests due to this.

@chuan chuan force-pushed the chuan/value-link-rel-complete branch from 41ddb32 to 6bf534f Compare December 9, 2021 05:12
* (parent)-[first_child_offset]->(child)
* (child)-[next_child_offset]->(child)
* (child)-[parent_offset]->(parent)
* A reference anchor chain will look like the following graph.

Choose a reason for hiding this comment

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

I'm missing something. I understand the need to the anchor node, but why do we now have previous_node link as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Otherwise, deleting a child node can take O(n), as is the case right now. I have created an item to replace all chain with the anchor chain.

Copy link
Contributor

Choose a reason for hiding this comment

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

So, in the future, all chains will be of the second type, or is there still a use case for this original approach?

Copy link
Contributor Author

@chuan chuan Dec 10, 2021

Choose a reason for hiding this comment

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

There are some trade-offs. I summarized in the JIRA item: https://gaiaplatform.atlassian.net/browse/GAIAPLAT-1769

Tengiz suggested to keep one chain (of the second type) from code maintenance point of view. I don't think he is firm on this. If we find good use cases of the first type, we can still make it available.

@chuan chuan force-pushed the chuan/value-link-rel-complete branch from d04ff22 to 01d1c44 Compare December 9, 2021 21:41
Copy link
Contributor

@LaurentiuCristofor LaurentiuCristofor 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 not the expert in all parts of this change, but I don't see any issues in the code I do understand. :)

production/db/core/src/gaia_ptr_client.cpp Outdated Show resolved Hide resolved
gaia_type_t child_type,
gaia_id_t* child_references,
const uint8_t* child_payload)
void gaia_ptr_t::auto_connect(
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is quite large. Is there no opportunity here for pulling some of this code into some helper functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have divided the method into two: parent side and child side.

production/db/core/src/gaia_ptr_client.cpp Outdated Show resolved Hide resolved
@chuan chuan force-pushed the chuan/value-link-rel-complete branch from 01d1c44 to cd81bba Compare December 10, 2021 09:25
@chuan chuan force-pushed the chuan/value-link-rel-complete branch from cd81bba to 430bbc5 Compare December 10, 2021 19:42
@chuan chuan merged commit 48a980a into master Dec 11, 2021
@chuan chuan deleted the chuan/value-link-rel-complete branch December 11, 2021 02:45
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.

4 participants