Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

optimize transactions #2

Merged
merged 1 commit into from
May 29, 2024
Merged

optimize transactions #2

merged 1 commit into from
May 29, 2024

Conversation

ranesagar
Copy link
Owner

@ranesagar ranesagar commented May 29, 2024

Optimizing solution -
Previously, due to copying the entire DATABASE during a begin(), the memory usage was getting doubled which was in-efficient.

To optimize, this change introduces two maps - deletedKey and deletedValue which keep track of deleted keys and corresponding occurrences of upserted keys in the current transaction.

get() - now recursively searches for the key till root node
set() - Before set a value, check with get() if the value exists and then handle the upsert.
commit() - Deep merges each map as we go up till the root node.

@ranesagar ranesagar merged commit ddccccb into main May 29, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant