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

Add insert_or_replace methods #57

Merged
merged 1 commit into from
Oct 22, 2024
Merged

Add insert_or_replace methods #57

merged 1 commit into from
Oct 22, 2024

Conversation

gsserge
Copy link
Contributor

@gsserge gsserge commented Oct 21, 2024

Add Tree::insert_or_replace and Tree::insert_or_replace_unchecked methods. They will be used in SurrealKV configured to run without versions. The idea is that since we don't need to keep previous versions of values in the index in memory, then for the existing keys we can simply replace the previous value with the new one by using Tree::insert_or_replace. Tree::insert_or_replace_unchecked is used for loading the index, so we only keep the value with the largest version, i.e. the most recent one.

A few notes:

  1. The implementation is simple but not the most optimised one. In the future we might want to add a special method for Twig nodes instead of clearing all existing values and then doing insert_mut().
  2. This implementation is not sufficient for handling the online compaction with versions enabled, but let's cross that bridge when we get there. Currently the focus is to handle the case without versions.

src/art.rs Outdated Show resolved Hide resolved
@gsserge gsserge merged commit b84885e into main Oct 22, 2024
1 check passed
@gsserge gsserge deleted the insert_or_replace branch October 22, 2024 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants