From 44ca5f824cecacc297776efe6308239204be56b5 Mon Sep 17 00:00:00 2001 From: g2hhh2ee Date: Sat, 29 Jul 2023 16:04:53 +0900 Subject: [PATCH 1/3] Fix invalid link --- design/housekeeping.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/design/housekeeping.md b/design/housekeeping.md index 1130d63b1..b5846ea71 100644 --- a/design/housekeeping.md +++ b/design/housekeeping.md @@ -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. From f34c75c84d2d752e2ea69758d841a67e74bb961c Mon Sep 17 00:00:00 2001 From: se030 Date: Sat, 29 Jul 2023 16:18:02 +0900 Subject: [PATCH 2/3] Fix typos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Data Structures ln47 remove "'" - Range Deletion in Splay Tree ln28 'avobe' → 'above' - Range Deletion in Splay Tree ln18 'tree from' → 'tree structure' (more appropriate phrase) --- design/data-structure.md | 6 +++--- design/range-deletion-in-splay-tree.md | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/design/data-structure.md b/design/data-structure.md index ec4711bb2..beeba1d1e 100644 --- a/design/data-structure.md +++ b/design/data-structure.md @@ -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](). - `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: @@ -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). \ No newline at end of file +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). diff --git a/design/range-deletion-in-splay-tree.md b/design/range-deletion-in-splay-tree.md index 114f25f78..cc479337a 100644 --- a/design/range-deletion-in-splay-tree.md +++ b/design/range-deletion-in-splay-tree.md @@ -2,6 +2,7 @@ title: delete-range-in-splay-tree target-version: 0.2.12 --- + --- # Range Deletion in Splay Tree @@ -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 @@ -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) @@ -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) @@ -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. From d8427de4584e3faaeb8bd5531de92dadacf99eba Mon Sep 17 00:00:00 2001 From: se <63814960+se030@users.noreply.github.com> Date: Sat, 29 Jul 2023 17:46:32 +0900 Subject: [PATCH 3/3] Remove unnecessary brackets --- design/data-structure.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/design/data-structure.md b/design/data-structure.md index beeba1d1e..b736810a2 100644 --- a/design/data-structure.md +++ b/design/data-structure.md @@ -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](). +- `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)). - `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: