changeset 359:c2487d69ede0

db_impl: Move code for finding oldest snapshot into start_compaction
author Lewin Bormann <lbo@spheniscida.de>
date Fri, 06 Oct 2017 06:13:20 +0000
parents 88c71cbd76a7
children 803cd9917c82
files src/db_impl.rs
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/db_impl.rs	Thu Oct 05 20:25:37 2017 +0200
+++ b/src/db_impl.rs	Fri Oct 06 06:13:20 2017 +0000
@@ -584,7 +584,12 @@
                 Ok(())
             }
         } else {
-            let mut state = CompactionState::new(compaction);
+            let smallest = if self.snaps.empty() {
+                self.vset.borrow().last_seq
+            } else {
+                self.snaps.oldest()
+            };
+            let mut state = CompactionState::new(compaction, smallest);
             if let Err(e) = self.do_compaction_work(&mut state) {
                 state.cleanup(&self.opt.env, &self.name);
                 log!(self.opt.log, "Compaction work failed: {}", e);
@@ -672,12 +677,6 @@
         assert!(self.vset.borrow().num_level_files(cs.compaction.level()) > 0);
         assert!(cs.builder.is_none());
 
-        cs.smallest_seq = if self.snaps.empty() {
-            self.vset.borrow().last_seq
-        } else {
-            self.snaps.oldest()
-        };
-
         let mut input = self.vset.borrow().make_input_iterator(&cs.compaction);
         input.seek_to_first();
 
@@ -830,10 +829,10 @@
 }
 
 impl CompactionState {
-    fn new(c: Compaction) -> CompactionState {
+    fn new(c: Compaction, smallest: SequenceNumber) -> CompactionState {
         CompactionState {
             compaction: c,
-            smallest_seq: 0,
+            smallest_seq: smallest,
             outputs: vec![],
             builder: None,
             total_bytes: 0,