File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -205,9 +205,19 @@ impl DustData {
205205 self . lsm . contains ( key)
206206 }
207207
208+ /// List all keys.
209+ /// # Returns
210+ /// - `Result<Vec<String>>` a vector of all keys.
208211 pub fn list_keys ( & self ) -> Result < Vec < String > > {
209212 Ok ( self . lsm . list_keys ( ) )
210213 }
214+
215+ /// Flush all data to disk.
216+ /// # Returns
217+ /// - `Result<()>` if successful returns nothing.
218+ pub fn flush ( & mut self ) -> Result < ( ) > {
219+ self . lsm . flush ( )
220+ }
211221}
212222
213223#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ mod dustdata_tests {
107107 . unwrap ( ) ;
108108
109109 // flush the sstable
110- dd. lsm . flush ( ) ;
110+ dd. flush ( ) . unwrap ( ) ;
111111
112112 let ls = dd. list_keys ( ) . unwrap ( ) ;
113113
Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ impl Lsm {
128128 self . bloom_filter . lock ( ) . unwrap ( ) . insert ( key) ;
129129
130130 if self . memtable_size >= self . lsm_config . flush_threshold {
131- self . flush ( ) ;
131+ self . flush ( ) . unwrap ( ) ;
132132 }
133133
134134 Ok ( ( ) )
@@ -204,7 +204,7 @@ impl Lsm {
204204 Ok ( ( ) )
205205 }
206206
207- pub fn flush ( & mut self ) {
207+ pub fn flush ( & mut self ) -> Result < ( ) > {
208208 if self . lsm_config . verbose {
209209 logs ! ( "Flushing memtable to disk..." ) ;
210210 }
@@ -237,6 +237,8 @@ impl Lsm {
237237
238238 self . memtable . lock ( ) . unwrap ( ) . clear ( ) ;
239239 self . memtable_size = 0 ;
240+
241+ Ok ( ( ) )
240242 }
241243
242244 pub fn get_memtable ( & self ) -> BTreeMap < String , bson:: Bson > {
You can’t perform that action at this time.
0 commit comments