3 ms·
Yes they’re quite similar. And I don’t think that’s a coincidence. But they have some important differences too: - Sumtree at its heart is a tree of character
by josephg 2y ago
Yes they’re quite similar. And I don’t think that’s a coincidence.
But they have some important differences too:
- Sumtree at its heart is a tree of characters, with a summary per node in the tree. I haven’t read that link in detail, but I assume summaries are derived from the stored text itself. I’m storing a tree of metadata entries, not text. The metadata is not derived from the text. A string of 100 characters in the document may be able to be summarised by 1 metadata entry, or we may need up to 100 entries - 1 for each character. Each leaf node in my tree stores up to 32 metadata entries. These entries are split when needed, and opportunistically joined. Entries describe characters which were at some point inserted. (We also need to keep around the metadata even after the text has been deleted.)
- My metadata entries also have IDs, and my data structure also needs to be able to look up any item in log(n) time via its ID.
The text itself is stored in a separate data structure. I assume any text editor which integrates a crdt will, like zed, have its own data structure for this purpose already.
You’re right that the data structures are similar, but the implementations are not interchangeable.