Skip to content

Commit

Permalink
Add path example
Browse files Browse the repository at this point in the history
  • Loading branch information
MoonGyu1 authored Aug 25, 2023
1 parent 9af9634 commit 105bead
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions design/concurrent-tree-editing.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ In yorkie, a JSON-like `Tree` is used to represent the document model of a tree-

This tree-based document model resembles XML tree and consists of element nodes and text nodes. element nodes can have attributes, and text nodes contain a string as their value. For example:

<img src="https://github.com/yorkie-team/yorkie/assets/78714820/b5500d8b-43db-4d89-983d-5708b7041cc4" width="500" />
<img src="https://github.com/yorkie-team/yorkie/assets/78714820/b5500d8b-43db-4d89-983d-5708b7041cc4" width="550" />


**Operation**

The JSON-like `Tree` provides specialized operations tailored for text editing rather than typical operations of a general tree. To specify the operation's range, an `index` is used. For example:
The JSON-like `Tree` provides specialized operations tailored for text editing rather than typical operations of a general tree. To specify the operation's range, an `index` or `path` is used. For example:

<img src="https://github.com/yorkie-team/yorkie/assets/78714820/88d6acde-6775-4af2-ae32-ba7a6b324abc" width="450" />
<img src="https://github.com/yorkie-team/yorkie/assets/78714820/9b3420e9-6c18-4114-9f4f-1c8e02324dd6" width="550" />

These `index`es are assigned in order at positions where the user's cursor can reach. These `index`es draw inspiration from ProseMirror's index and share a similar structural concept.

In the case of a `path`, it contains `offset`s of each node from the root node as elements except the last. The last element of the `path` represents the position in the parent node. For example, the `path` of the position between '`k`' and '`i`' is `[1, 4]`. The first element of the `path` is the `offset` of the `<b>` in `<p>` and the second element represents the position between '`k`' and '`i`' in `<b>`.

1. `Tree.Edit`

Users can use the `Edit` operation to insert or delete nodes within the `Tree`.
Expand Down Expand Up @@ -119,7 +121,7 @@ In the case of local editing, the given `index`es are converted to `CRDTTree.Tre

**Coverage**

<img src="https://github.com/yorkie-team/yorkie/assets/78714820/c911ffb4-9021-4a1f-9a11-b8e28fb41435" width="850" >
<img src="https://github.com/yorkie-team/yorkie/assets/78714820/c911ffb4-9021-4a1f-9a11-b8e28fb41435" width="750" >

Using conditions such as range type, node type, and edit type, 27 possible cases of concurrent editing can be represented.

Expand Down

1 comment on commit 105bead

@github-actions
Copy link

Choose a reason for hiding this comment

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

Go Benchmark

Benchmark suite Current: 105bead Previous: e0e7b17 Ratio
BenchmarkDocument/constructor_test - ns/op 1544 ns/op 1631 ns/op 0.95
BenchmarkDocument/constructor_test - B/op 984 B/op 984 B/op 1
BenchmarkDocument/constructor_test - allocs/op 16 allocs/op 16 allocs/op 1
BenchmarkDocument/status_test - ns/op 901.2 ns/op 1568 ns/op 0.57
BenchmarkDocument/status_test - B/op 952 B/op 952 B/op 1
BenchmarkDocument/status_test - allocs/op 14 allocs/op 14 allocs/op 1
BenchmarkDocument/equals_test - ns/op 8652 ns/op 9842 ns/op 0.88
BenchmarkDocument/equals_test - B/op 6192 B/op 6192 B/op 1
BenchmarkDocument/equals_test - allocs/op 106 allocs/op 106 allocs/op 1
BenchmarkDocument/nested_update_test - ns/op 21761 ns/op 25128 ns/op 0.87
BenchmarkDocument/nested_update_test - B/op 11689 B/op 11689 B/op 1
BenchmarkDocument/nested_update_test - allocs/op 248 allocs/op 248 allocs/op 1
BenchmarkDocument/delete_test - ns/op 35334 ns/op 33223 ns/op 1.06
BenchmarkDocument/delete_test - B/op 14915 B/op 14913 B/op 1.00
BenchmarkDocument/delete_test - allocs/op 327 allocs/op 327 allocs/op 1
BenchmarkDocument/object_test - ns/op 10426 ns/op 11854 ns/op 0.88
BenchmarkDocument/object_test - B/op 6448 B/op 6449 B/op 1.00
BenchmarkDocument/object_test - allocs/op 110 allocs/op 110 allocs/op 1
BenchmarkDocument/array_test - ns/op 35821 ns/op 40251 ns/op 0.89
BenchmarkDocument/array_test - B/op 11545 B/op 11546 B/op 1.00
BenchmarkDocument/array_test - allocs/op 264 allocs/op 264 allocs/op 1
BenchmarkDocument/text_test - ns/op 38570 ns/op 42988 ns/op 0.90
BenchmarkDocument/text_test - B/op 14618 B/op 14618 B/op 1
BenchmarkDocument/text_test - allocs/op 470 allocs/op 470 allocs/op 1
BenchmarkDocument/text_composition_test - ns/op 39378 ns/op 44497 ns/op 0.88
BenchmarkDocument/text_composition_test - B/op 18002 B/op 18002 B/op 1
BenchmarkDocument/text_composition_test - allocs/op 471 allocs/op 471 allocs/op 1
BenchmarkDocument/rich_text_test - ns/op 103268 ns/op 121385 ns/op 0.85
BenchmarkDocument/rich_text_test - B/op 36814 B/op 36807 B/op 1.00
BenchmarkDocument/rich_text_test - allocs/op 1131 allocs/op 1131 allocs/op 1
BenchmarkDocument/counter_test - ns/op 21108 ns/op 24778 ns/op 0.85
BenchmarkDocument/counter_test - B/op 9969 B/op 9971 B/op 1.00
BenchmarkDocument/counter_test - allocs/op 235 allocs/op 235 allocs/op 1
BenchmarkDocument/text_edit_gc_100 - ns/op 3967267 ns/op 4953916 ns/op 0.80
BenchmarkDocument/text_edit_gc_100 - B/op 1553145 B/op 1553154 B/op 1.00
BenchmarkDocument/text_edit_gc_100 - allocs/op 17162 allocs/op 17162 allocs/op 1
BenchmarkDocument/text_edit_gc_1000 - ns/op 312158477 ns/op 415539332 ns/op 0.75
BenchmarkDocument/text_edit_gc_1000 - B/op 136644668 B/op 136654077 B/op 1.00
BenchmarkDocument/text_edit_gc_1000 - allocs/op 210769 allocs/op 210807 allocs/op 1.00
BenchmarkDocument/text_split_gc_100 - ns/op 4568282 ns/op 5163744 ns/op 0.88
BenchmarkDocument/text_split_gc_100 - B/op 2217629 B/op 2217867 B/op 1.00
BenchmarkDocument/text_split_gc_100 - allocs/op 16591 allocs/op 16589 allocs/op 1.00
BenchmarkDocument/text_split_gc_1000 - ns/op 371130944 ns/op 459261506 ns/op 0.81
BenchmarkDocument/text_split_gc_1000 - B/op 214852845 B/op 214825368 B/op 1.00
BenchmarkDocument/text_split_gc_1000 - allocs/op 211425 allocs/op 211278 allocs/op 1.00
BenchmarkDocument/text_delete_all_10000 - ns/op 19279777 ns/op 21640628 ns/op 0.89
BenchmarkDocument/text_delete_all_10000 - B/op 5902985 B/op 5904350 B/op 1.00
BenchmarkDocument/text_delete_all_10000 - allocs/op 41121 allocs/op 41125 allocs/op 1.00
BenchmarkDocument/text_delete_all_100000 - ns/op 233748721 ns/op 293915504 ns/op 0.80
BenchmarkDocument/text_delete_all_100000 - B/op 53829176 B/op 53849444 B/op 1.00
BenchmarkDocument/text_delete_all_100000 - allocs/op 415934 allocs/op 416019 allocs/op 1.00
BenchmarkDocument/text_100 - ns/op 319530 ns/op 368364 ns/op 0.87
BenchmarkDocument/text_100 - B/op 118211 B/op 118211 B/op 1
BenchmarkDocument/text_100 - allocs/op 5074 allocs/op 5074 allocs/op 1
BenchmarkDocument/text_1000 - ns/op 3499563 ns/op 4020698 ns/op 0.87
BenchmarkDocument/text_1000 - B/op 1152793 B/op 1152828 B/op 1.00
BenchmarkDocument/text_1000 - allocs/op 50078 allocs/op 50078 allocs/op 1
BenchmarkDocument/array_1000 - ns/op 1759268 ns/op 1982625 ns/op 0.89
BenchmarkDocument/array_1000 - B/op 1102701 B/op 1102720 B/op 1.00
BenchmarkDocument/array_1000 - allocs/op 11867 allocs/op 11867 allocs/op 1
BenchmarkDocument/array_10000 - ns/op 20493483 ns/op 24133350 ns/op 0.85
BenchmarkDocument/array_10000 - B/op 9906365 B/op 9908265 B/op 1.00
BenchmarkDocument/array_10000 - allocs/op 120717 allocs/op 120725 allocs/op 1.00
BenchmarkDocument/array_gc_100 - ns/op 182249 ns/op 218206 ns/op 0.84
BenchmarkDocument/array_gc_100 - B/op 98156 B/op 98170 B/op 1.00
BenchmarkDocument/array_gc_100 - allocs/op 1243 allocs/op 1243 allocs/op 1
BenchmarkDocument/array_gc_1000 - ns/op 1965542 ns/op 2439002 ns/op 0.81
BenchmarkDocument/array_gc_1000 - B/op 1170493 B/op 1170334 B/op 1.00
BenchmarkDocument/array_gc_1000 - allocs/op 12906 allocs/op 12906 allocs/op 1
BenchmarkDocument/counter_1000 - ns/op 288620 ns/op 348837 ns/op 0.83
BenchmarkDocument/counter_1000 - B/op 198534 B/op 198533 B/op 1.00
BenchmarkDocument/counter_1000 - allocs/op 6503 allocs/op 6503 allocs/op 1
BenchmarkDocument/counter_10000 - ns/op 3138970 ns/op 3797783 ns/op 0.83
BenchmarkDocument/counter_10000 - B/op 2165435 B/op 2165466 B/op 1.00
BenchmarkDocument/counter_10000 - allocs/op 69510 allocs/op 69510 allocs/op 1
BenchmarkDocument/object_1000 - ns/op 1880671 ns/op 2176596 ns/op 0.86
BenchmarkDocument/object_1000 - B/op 1451191 B/op 1451413 B/op 1.00
BenchmarkDocument/object_1000 - allocs/op 9915 allocs/op 9915 allocs/op 1
BenchmarkDocument/object_10000 - ns/op 22999745 ns/op 29075180 ns/op 0.79
BenchmarkDocument/object_10000 - B/op 12369460 B/op 12368142 B/op 1.00
BenchmarkDocument/object_10000 - allocs/op 101220 allocs/op 101216 allocs/op 1.00
BenchmarkRPC/client_to_server - ns/op 426806666 ns/op 623741911 ns/op 0.68
BenchmarkRPC/client_to_server - B/op 12229672 B/op 12446728 B/op 0.98
BenchmarkRPC/client_to_server - allocs/op 176900 allocs/op 177074 allocs/op 1.00
BenchmarkRPC/client_to_client_via_server - ns/op 712968256 ns/op 1007493091 ns/op 0.71
BenchmarkRPC/client_to_client_via_server - B/op 22571348 B/op 22360952 B/op 1.01
BenchmarkRPC/client_to_client_via_server - allocs/op 330627 allocs/op 315734 allocs/op 1.05
BenchmarkRPC/attach_large_document - ns/op 1436327288 ns/op 1462175961 ns/op 0.98
BenchmarkRPC/attach_large_document - B/op 1800323208 B/op 1799019544 B/op 1.00
BenchmarkRPC/attach_large_document - allocs/op 9567 allocs/op 9450 allocs/op 1.01
BenchmarkRPC/adminCli_to_server - ns/op 602316398 ns/op 824637910 ns/op 0.73
BenchmarkRPC/adminCli_to_server - B/op 20391360 B/op 20415996 B/op 1.00
BenchmarkRPC/adminCli_to_server - allocs/op 321613 allocs/op 321647 allocs/op 1.00
BenchmarkLocker - ns/op 124 ns/op 144.4 ns/op 0.86
BenchmarkLocker - B/op 16 B/op 16 B/op 1
BenchmarkLocker - allocs/op 1 allocs/op 1 allocs/op 1
BenchmarkLockerParallel - ns/op 123.4 ns/op 142.7 ns/op 0.86
BenchmarkLockerParallel - B/op 0 B/op 0 B/op NaN
BenchmarkLockerParallel - allocs/op 0 allocs/op 0 allocs/op NaN
BenchmarkLockerMoreKeys - ns/op 236.8 ns/op 330.2 ns/op 0.72
BenchmarkLockerMoreKeys - B/op 15 B/op 15 B/op 1
BenchmarkLockerMoreKeys - allocs/op 0 allocs/op 0 allocs/op NaN
BenchmarkSync/memory_sync_10_test - ns/op 7345 ns/op 8751 ns/op 0.84
BenchmarkSync/memory_sync_10_test - B/op 1284 B/op 1284 B/op 1
BenchmarkSync/memory_sync_10_test - allocs/op 38 allocs/op 38 allocs/op 1
BenchmarkSync/memory_sync_100_test - ns/op 66308 ns/op 79832 ns/op 0.83
BenchmarkSync/memory_sync_100_test - B/op 8840 B/op 8908 B/op 0.99
BenchmarkSync/memory_sync_100_test - allocs/op 285 allocs/op 289 allocs/op 0.99
BenchmarkSync/memory_sync_1000_test - ns/op 688124 ns/op 763146 ns/op 0.90
BenchmarkSync/memory_sync_1000_test - B/op 82002 B/op 82936 B/op 0.99
BenchmarkSync/memory_sync_1000_test - allocs/op 2597 allocs/op 2647 allocs/op 0.98
BenchmarkSync/memory_sync_10000_test - ns/op 7329338 ns/op 8311071 ns/op 0.88
BenchmarkSync/memory_sync_10000_test - B/op 857174 B/op 879987 B/op 0.97
BenchmarkSync/memory_sync_10000_test - allocs/op 26994 allocs/op 28295 allocs/op 0.95
BenchmarkTextEditing - ns/op 26925016922 ns/op 32727791991 ns/op 0.82
BenchmarkTextEditing - B/op 8457162880 B/op 8456442864 B/op 1.00
BenchmarkTextEditing - allocs/op 20615477 allocs/op 20611911 allocs/op 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.