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

Fix typos and invalid link in the yorkie design document #591

Merged
merged 3 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions design/data-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ JSON-like data strucutres are used when editing JSON-like documents.

- `Primitive`: represents primitive data like `string`, `number`, `boolean`, `null`, etc.
- `Object`: represents [object type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) of JavaScript. Just like JavaScript, you can use `Object` as [hash table](https://en.wikipedia.org/wiki/Hash_table).
- `Array`: represents [array type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of JavaScript. You can also use `Array` as [list](https://en.wikipedia.org/wiki/List_(abstract_data_type)).
- `Array`: represents [array type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of JavaScript. You can also use `Array` as [list](<https://en.wikipedia.org/wiki/List_(abstract_data_type)>).
krapie marked this conversation as resolved.
Show resolved Hide resolved
- `Text`: represents text with style attributes in rich text editors such as [Quill](https://github.com/yorkie-team/yorkie-js-sdk/blob/main/examples/quill.html). Users can express styles such as bold, italic, and underline to text content. Of course, it can represent just a plain text in text-based editors such as [CodeMirror](https://github.com/yorkie-team/yorkie-js-sdk/blob/main/examples/index.html). It supports collaborative editing; multiple users can modify parts of the contents without conflict.

JSON-like data structures can be edited through proxies. For example:
Expand Down Expand Up @@ -79,8 +79,8 @@ Common data structures can be used for general purposes.

- [`SplayTree`](https://en.wikipedia.org/wiki/Splay_tree): A tree that moves nodes to the root by splaying. This is effective when user frequently access the same location, such as text editing. We use `SplayTree` as an index tree to give each node a weight, and to quickly access the node based on the index.
- [`LLRBTree`](https://en.wikipedia.org/wiki/Left-leaning_red%E2%80%93black_tree): A tree simpler than Red-Black Tree. Newly added `floor` method finds the node of the largest key less than or equal to the given key.
- [`Trie`](https://en.wikipedia.org/wiki/Trie): A data structure that can quickly search for prefixes of sequence data such as strings. We use `Trie` to remove nested events when the contents of the `Document`' are modified at once.
- [`Trie`](https://en.wikipedia.org/wiki/Trie): A data structure that can quickly search for prefixes of sequence data such as strings. We use `Trie` to remove nested events when the contents of the `Document` are modified at once.

### Risks and Mitigation

We can replace the data structures with better ones for some reason, such as performance. For example, `SplayTree` used in `RGATreeList` can be replaced with [TreeList](https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/list/TreeList.html).
We can replace the data structures with better ones for some reason, such as performance. For example, `SplayTree` used in `RGATreeList` can be replaced with [TreeList](https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/list/TreeList.html).
4 changes: 1 addition & 3 deletions design/housekeeping.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ target-version: 0.2.1

## Summary

We provide Garbage Collection to purge tombstones and prevent the problem of
We provide [Garbage Collection](garbage-collection.md) to purge tombstones and prevent the problem of
documents growing.

https://yorkie.dev/docs/garbage-collection

However, when there are clients that has been editing old documents but have not
been used for a long time, garbage collection becomes less efficient.

Expand Down
12 changes: 7 additions & 5 deletions design/range-deletion-in-splay-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: delete-range-in-splay-tree
target-version: 0.2.12
---

---

# Range Deletion in Splay Tree
Expand All @@ -14,7 +15,7 @@ Using the feature of a splay tree that changes the root freely, `splay.DeleteRan

### Goals

The function `DeleteRange` should separate all nodes exactly in the given range as a subtree. After executing the function, the entire tree from and weight of every node must be correct just as when the nodes were deleted one by one.
The function `DeleteRange` should separate all nodes exactly in the given range as a subtree. After executing the function, the entire tree structure and weight of every node must be correct just as when the nodes were deleted one by one.

## Proposal Details

Expand All @@ -24,8 +25,7 @@ From the property of indexed BST, all nodes with a smaller index than the root a

And also, Splay Tree can change the root freely to use `Splay`.

Then using the properties, when we want to delete the range from index `L` to `R` we can make the shape of tree like the figure avobe to `Splay(L-1)` then `Splay(R+1)`.

Then using the properties, when we want to delete the range from index `L` to `R` we can make the shape of tree like the figure above to `Splay(L-1)` then `Splay(R+1)`.

![delete-range-in-splay-tree-2](./media/range-deletion-in-splay-tree-2-separation.png)

Expand All @@ -39,10 +39,10 @@ func (t *Tree[V]) DeleteRange(leftBoundary, rightBoundary *Node[V]) {
t.cutOffRight(leftBoundary)
return
}

t.Splay(leftBoundary)
t.Splay(rightBoundary)

// refer case 2 of second figure
if rightBoundary.left != leftBoundary {
t.rotateRight(leftBoundary)
Expand All @@ -51,9 +51,11 @@ func (t *Tree[V]) DeleteRange(leftBoundary, rightBoundary *Node[V]) {
}

```

Sometimes the tree shapes like case 2 after `Splay`s because of the zig-zig case of `Splay`. But it simply changes to the same shapes as case 1 in one rotation for `L-1`.

Then now to cut off the right child(subtree) of `L-1`, we can separate all nodes in the given range to be deleted.

### Risks and Mitigation

`DeleteRange` does not consider the occurrence of new nodes due to concurrent editing in the range to be deleted. They should be filtered before using `DeleteRange`, and `DeleteRange` should be executed continuously in the smaller ranges that do not include them.
Expand Down