Mercurial > lbo > hg > leveldb-rs
changeset 603:6c504100f8f9
Merge pull request #29 from EmoFuncs/fix_bug_recover_db
fix bug: largest key of sstable is the last key inserted into the table
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Tue, 20 Jun 2023 15:49:15 +0200 |
parents | 6cebf0ac5f8b (current diff) 45b51fa84885 (diff) |
children | 107595106b55 |
files | |
diffstat | 1 files changed, 4 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/db_impl.rs Thu Jun 08 19:47:16 2023 +0200 +++ b/src/db_impl.rs Tue Jun 20 15:49:15 2023 +0200 @@ -807,7 +807,7 @@ // case. assert!(input.current(&mut key, &mut val)); if cs.compaction.should_stop_before(&key) && cs.builder.is_some() { - self.finish_compaction_output(cs, key.clone())?; + self.finish_compaction_output(cs)?; } let (ktyp, seq, ukey) = parse_internal_key(&key); if seq == 0 { @@ -861,17 +861,18 @@ if cs.builder.as_ref().unwrap().entries() == 0 { cs.current_output().smallest = key.clone(); } + cs.current_output().largest = key.clone(); cs.builder.as_mut().unwrap().add(&key, &val)?; // NOTE: Adjust max file size based on level. if cs.builder.as_ref().unwrap().size_estimate() > self.opt.max_file_size { - self.finish_compaction_output(cs, key.clone())?; + self.finish_compaction_output(cs)?; } input.advance(); } if cs.builder.is_some() { - self.finish_compaction_output(cs, key)?; + self.finish_compaction_output(cs)?; } let mut stats = CompactionStats::default(); @@ -891,7 +892,6 @@ fn finish_compaction_output( &mut self, cs: &mut CompactionState, - largest: Vec<u8>, ) -> Result<()> { assert!(cs.builder.is_some()); let output_num = cs.current_output().num; @@ -905,7 +905,6 @@ let bytes = b.finish()?; cs.total_bytes += bytes; - cs.current_output().largest = largest; cs.current_output().size = bytes; if entries > 0 {