@@ -6,7 +6,6 @@ use std::sync::{Arc, Mutex};
66
77use crate :: bloom:: BloomFilter ;
88use crate :: dustdata:: { Error , ErrorCode , Result } ;
9- use crate :: logs;
109
1110use self :: snapshots:: Snapshot ;
1211
@@ -20,7 +19,6 @@ mod writer;
2019pub struct LsmConfig {
2120 pub flush_threshold : usize ,
2221 pub sstable_path : String ,
23- pub verbose : bool ,
2422}
2523
2624#[ derive( Clone ) ]
@@ -71,53 +69,6 @@ impl Lsm {
7169 }
7270 }
7371
74- pub fn handle_ctrlc ( & mut self ) {
75- let c_mem = Arc :: clone ( & self . memtable ) ;
76- let c_den = Arc :: clone ( & self . dense_index ) ;
77- let c_config = self . lsm_config . clone ( ) ;
78- let c_bloom = Arc :: clone ( & self . bloom_filter ) ;
79-
80- ctrlc:: set_handler ( move || {
81- if c_config. verbose {
82- logs ! ( "Ctrl-C detected." ) ;
83- }
84-
85- let memtable = c_mem. lock ( ) . unwrap ( ) ;
86- let mut dense_index = c_den. lock ( ) . unwrap ( ) ;
87-
88- if memtable. is_empty ( ) {
89- if c_config. verbose {
90- logs ! ( "No data to flush." ) ;
91- }
92-
93- std:: process:: exit ( 0 ) ;
94- }
95-
96- if c_config. verbose {
97- logs ! ( "Flushing memtable to disk..." ) ;
98- }
99-
100- let segments =
101- sstable:: Segment :: from_tree ( memtable. deref ( ) , c_config. sstable_path . as_str ( ) ) ;
102-
103- for token in segments. 1 {
104- dense_index. insert ( token. 0 , token. 1 ) ;
105- }
106-
107- let mut keys = Vec :: new ( ) ;
108-
109- for segment in dense_index. deref ( ) {
110- keys. push ( segment. 0 . clone ( ) ) ;
111- }
112-
113- index:: write_index ( & c_config. sstable_path , dense_index. deref ( ) ) ;
114- filter:: write_filter ( & c_config. sstable_path , c_bloom. lock ( ) . unwrap ( ) . deref ( ) ) ;
115-
116- std:: process:: exit ( 0 ) ;
117- } )
118- . ok ( ) ;
119- }
120-
12172 pub fn insert ( & mut self , key : & str , value : bson:: Bson ) -> Result < ( ) > {
12273 if self . contains ( key) {
12374 return Err ( Error {
@@ -211,10 +162,6 @@ impl Lsm {
211162 pub fn flush ( & mut self ) -> Result < ( ) > {
212163 let memtable = self . get_memtable ( ) ;
213164
214- if self . lsm_config . verbose {
215- logs ! ( "Flushing memtable to disk..." ) ;
216- }
217-
218165 if memtable. is_empty ( ) {
219166 return Ok ( ( ) ) ;
220167 }
@@ -302,22 +249,10 @@ impl Drop for Lsm {
302249 let memtable = self . memtable . lock ( ) . unwrap ( ) ;
303250 let mut dense_index = self . dense_index . lock ( ) . unwrap ( ) ;
304251
305- if self . lsm_config . verbose {
306- logs ! ( "LSM is being dropped." ) ;
307- }
308-
309252 if memtable. is_empty ( ) {
310- if self . lsm_config . verbose {
311- logs ! ( "No memtable to flush to disk." ) ;
312- }
313-
314253 return ;
315254 }
316255
317- if self . lsm_config . verbose {
318- logs ! ( "Flushing memtable to disk." ) ;
319- }
320-
321256 let segments =
322257 sstable:: Segment :: from_tree ( memtable. deref ( ) , self . lsm_config . sstable_path . as_str ( ) ) ;
323258
0 commit comments