changeset 324:4637c87d8b47

db_impl: Adopt new auto-cleanup API for snapshots.
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 01 Oct 2017 14:17:49 +0000
parents c8288b1ca724
children f39d34cf05e5
files src/db_impl.rs src/memtable.rs
diffstat 2 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/db_impl.rs	Sun Oct 01 14:17:36 2017 +0000
+++ b/src/db_impl.rs	Sun Oct 01 14:17:49 2017 +0000
@@ -440,13 +440,11 @@
 
 impl DB {
     // SNAPSHOTS //
+
+    /// Returns a snapshot at the current state. The snapshot is released automatically on Drop.
     pub fn get_snapshot(&mut self) -> Snapshot {
         self.snaps.new_snapshot(self.vset.last_seq)
     }
-
-    pub fn release_snapshot(&mut self, snapshot: Snapshot) {
-        self.snaps.delete(snapshot)
-    }
 }
 
 impl DB {
@@ -1148,10 +1146,11 @@
         assert!(db.get_internal(3, "eab".as_bytes()).unwrap().is_none());
         assert!(db.get_internal(30, "eab".as_bytes()).unwrap().is_some());
 
-        let ss = db.get_snapshot();
-        assert_eq!("val2".as_bytes(),
-                   db.get_at(&ss, "eab".as_bytes()).unwrap().unwrap().as_slice());
-        db.release_snapshot(ss);
+        {
+            let ss = db.get_snapshot();
+            assert_eq!("val2".as_bytes(),
+                       db.get_at(&ss, "eab".as_bytes()).unwrap().unwrap().as_slice());
+        }
     }
 
     #[test]
--- a/src/memtable.rs	Sun Oct 01 14:17:36 2017 +0000
+++ b/src/memtable.rs	Sun Oct 01 14:17:49 2017 +0000
@@ -59,7 +59,7 @@
                 if tag & 0xff == ValueType::TypeValue as u64 {
                     return Some(foundkey[valoff..valoff + vallen].to_vec());
                 } else {
-                    return None
+                    return None;
                 }
             }
         }