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

Remove Snapshot #63

Merged
merged 1 commit into from
Oct 24, 2024
Merged

Remove Snapshot #63

merged 1 commit into from
Oct 24, 2024

Conversation

gsserge
Copy link
Contributor

@gsserge gsserge commented Oct 24, 2024

Due to its Copy-on-Write nature, creating a snapshot of the tree is just a matter of cloning it, e.g. tree.clone().

Some of the snapshot tests are moved to the art.rs module with small modifications.

@gsserge gsserge requested a review from arriqaaq October 24, 2024 14:17
@arriqaaq
Copy link
Contributor

Can we add this test back just to verify behaviour of SI

    #[test]
    fn snapshot_isolation() {
        let mut tree: Tree<VariableSizeKey, i32> = Tree::<VariableSizeKey, i32>::new();
        let key_1 = VariableSizeKey::from_str("key_1").unwrap();
        let key_2 = VariableSizeKey::from_str("key_2").unwrap();
        let key_3_snap1 = VariableSizeKey::from_str("key_3_snap1").unwrap();
        let key_3_snap2 = VariableSizeKey::from_str("key_3_snap2").unwrap();

        assert!(tree.insert(&key_1, 1, 0, 0).is_ok());

        // Keys inserted before snapshot creation should be visible
        let mut snap1 = tree.clone();
        assert_eq!(snap1.get(&key_1, 0).unwrap(), (1, 1, 0));

        let mut snap2 = tree.clone();
        assert_eq!(snap2.get(&key_1, 0).unwrap(), (1, 1, 0));

        // Keys inserted after snapshot creation should not be visible to other snapshots
        assert!(tree.insert(&key_2, 1, 0, 0).is_ok());
        assert!(snap1.get(&key_2, 0).is_none());
        assert!(snap2.get(&key_2, 0).is_none());

        // Keys inserted after snapshot creation should be visible to the snapshot that inserted them
        snap1.insert(&key_3_snap1, 2, 0, 0).unwrap();
        assert_eq!(snap1.get(&key_3_snap1, 0).unwrap(), (2, 2, 0));

        snap2.insert(&key_3_snap2, 3, 0, 0).unwrap();
        assert_eq!(snap2.get(&key_3_snap2, 0).unwrap(), (3, 2, 0));

        // Keys inserted after snapshot creation should not be visible to other snapshots
        assert!(snap1.get(&key_3_snap2, 0).is_none());
        assert!(snap2.get(&key_3_snap1, 0).is_none());
    }

@gsserge
Copy link
Contributor Author

gsserge commented Oct 24, 2024

@arriqaaq added the SI test

@gsserge gsserge merged commit 9d50346 into main Oct 24, 2024
1 check passed
@gsserge gsserge deleted the remove_snapshot branch October 24, 2024 16:46
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