Skip to content

snapshot memory to disk, new from snapshot - disk to memory#13

Open
backurs wants to merge 5 commits intomicrosoft:mainfrom
backurs:main
Open

snapshot memory to disk, new from snapshot - disk to memory#13
backurs wants to merge 5 commits intomicrosoft:mainfrom
backurs:main

Conversation

@backurs
Copy link
Contributor

@backurs backurs commented Feb 27, 2026

Current repo only allows to snapshot bftrees that are disk-based. If we want to snapshot a bftree that is memory-based, we get a segmentation fault.

This PR implements functionality to snapshot in-memory bftree to disk. It simply reads all records from the in-memory bftree, creates an on-disk empty bftree, where it writes all the records.

It also creates a complementary function that takes as an input a path to a snapshot-ed bftree, reads it to create a disk-based bftree, reads all entries from it, creates an empty in-memory bftree and writes all the entries to the in-memory bftree.

While working on this PR I encountered a compilation error in file src/tests/concurrent.rs - the compiler complained about uninitialized vector in these lines:

            let mut buffer = Vec::with_capacity(4096);
            unsafe { buffer.set_len(4096) };

So I replaced these lines with

            let mut buffer = vec![0u8; 4096];

which I think is equivalent.

@harsha-simhadri harsha-simhadri requested a review from badrishc March 3, 2026 16:23
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.

1 participant