diff --git a/tools/iface/src/db.rs b/tools/iface/src/db.rs index e6f31a3..50b2720 100644 --- a/tools/iface/src/db.rs +++ b/tools/iface/src/db.rs @@ -13,6 +13,8 @@ pub trait Database { fn names<'a>(&'a self) -> Vec>; fn segment<'a>(&'a mut self, name: Vec) -> Option>; // change return type to Result + + fn flush(&mut self); } pub trait Segment { @@ -54,8 +56,10 @@ pub fn copy_database( } drop(dst_seg); - drop(src_seg_iter); + drop(src_seg); + + dst.flush(); } Ok(()) diff --git a/tools/iface/src/db/heed.rs b/tools/iface/src/db/heed.rs index 8dc24f6..28eb481 100644 --- a/tools/iface/src/db/heed.rs +++ b/tools/iface/src/db/heed.rs @@ -64,6 +64,10 @@ impl Database for HeedDB { .map(|(k, _)| k) .collect_vec() } + + fn flush(&mut self) { + // NOOP + } } pub struct HeedSegment { env: heed::Env, diff --git a/tools/iface/src/db/rocksdb.rs b/tools/iface/src/db/rocksdb.rs index d50e979..63a3594 100644 --- a/tools/iface/src/db/rocksdb.rs +++ b/tools/iface/src/db/rocksdb.rs @@ -80,6 +80,10 @@ impl Database for RocksDB { .map(|v| v.as_bytes().to_vec()) .collect() } + + fn flush(&mut self) { + self.rocks.flush().unwrap() + } } impl Drop for RocksDB { diff --git a/tools/iface/src/db/sled.rs b/tools/iface/src/db/sled.rs index db25b03..f2d465f 100644 --- a/tools/iface/src/db/sled.rs +++ b/tools/iface/src/db/sled.rs @@ -33,6 +33,10 @@ impl Database for SledDB { .ok() .map(|t| -> Box { Box::new(t) }) } + + fn flush(&mut self) { + self.0.flush().unwrap(); + } } impl Segment for Tree { diff --git a/tools/iface/src/db/sqlite.rs b/tools/iface/src/db/sqlite.rs index ec6c03e..458e25b 100644 --- a/tools/iface/src/db/sqlite.rs +++ b/tools/iface/src/db/sqlite.rs @@ -64,6 +64,10 @@ impl Database for SqliteDB { name: string, })) } + + fn flush(&mut self) { + // NOOP + } } pub struct SqliteSegment<'a> {