project_note
Clone
https://git.tahinli.com/Tahinli/project_note.git
0 watching0 forksRust3.6 MiBc49f5e7Tahinli1 month ago2 commits
| 1 | //! The fork module provides functionality to create a new LoroDoc instance at a specified version |
| 2 | //! (Frontiers) with minimal overhead. |
| 3 | //! |
| 4 | //! # Implementation Overview |
| 5 | //! |
| 6 | //! The `fork_at` function in this module allows for the creation of a new document that reflects |
| 7 | //! the state of the original document at a given version. The function achieves this by: |
| 8 | //! |
| 9 | //! ## Exporting Necessary Data: |
| 10 | //! |
| 11 | //! - **Change Store Data**: Collects all changes up to the specified version from the change |
| 12 | //! store's key-value (kv) data store. It includes the version vector and frontiers for accurate |
| 13 | //! identification of the version. |
| 14 | //! |
| 15 | //! - **Container Store Data**: Exports the container store's kv data representing the document's |
| 16 | //! state at the specified version. This involves checking out to the desired version, exporting |
| 17 | //! the state, and efficiently checking back to the latest version. |
| 18 | //! |
| 19 | //! - **GC Store Data**: If applicable, exports the gc store's kv data, ensuring that version |
| 20 | //! identifiers are included. |
| 21 | //! |
| 22 | //! ## Reconstructing the New Document: |
| 23 | //! |
| 24 | //! Imports the exported data into a new LoroDoc instance using optimized import mechanisms |
| 25 | //! similar to those used in fast snapshot imports. |
| 26 | //! |
| 27 | //! By focusing on exporting only the necessary data and optimizing state transitions during |
| 28 | //! version checkout, the `fork_at` function minimizes overhead and efficiently creates new |
| 29 | //! document instances representing past versions. |
| 30 | //! |
| 31 | use Cow; |
| 32 | |
| 33 | use crate::; |
| 34 | use ; |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 |