-
Notifications
You must be signed in to change notification settings - Fork 75
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
Generate correct TreeChange in concurrent edits #712
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #712 +/- ##
==========================================
+ Coverage 81.75% 81.99% +0.23%
==========================================
Files 57 57
Lines 4161 4231 +70
Branches 805 828 +23
==========================================
+ Hits 3402 3469 +67
- Misses 502 503 +1
- Partials 257 259 +2 ☔ View full report in Codecov by Sentry. |
ef3d6e2
to
452924e
Compare
7554aef
to
7738777
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
Unlike JS SDK, this PR doesn't create TreeChanges, but it changes the traversal logic to be token-based to keep consistency. Changes: - Implements token traversal method. - Ensures accurate inclusion of tokens (Start/End/Text) in ranges. Related to yorkie-team/yorkie-js-sdk#712 --------- Co-authored-by: Youngteac Hong <susukang98@gmail.com>
What this PR does / why we need it?
This PR introduces the logic for generating correct TreeChange in concurrent edits.
The main functionalities are collecting nodes to be deleted and creating ranges by accumulating successive nodes in pre-order.
Any background context you want to provide?
Unlike the
Text
CRDT,Tree
has levels and an element node has tags (Opening
/Closing
).For multi-level
Tree
operations (e.g. merge), the determination of which tag is included is currently important. However, using the existing post-order traversal, it is hard to determine if two nodes are successive and if which tags of the node are included in the range.As a result, This PR introduces a new traversal method that visits all kinds of tag, which include
Opening
,Closing
, andText
.Alternatives for optimization
Optimizing by using the linked list (
prev
andnext
pointers) may be possible, but how to manage the links from theClosing
tag and to theClosing
tag should be considered.Like the
Text
CRDT, generating ranges using undeleted nodes for optimization may be also feasible, but this is likely to require to traverse tombstones.traverseInTreePos
logic to traverse tombstones as well, and generate ranges using undeleted nodesWhat are the relevant tickets?
Fixes yorkie-team/yorkie#732
Checklist