Skip to content

Commit

Permalink
remove dbg
Browse files Browse the repository at this point in the history
Signed-off-by: Fullstop000 <[email protected]>
  • Loading branch information
Fullstop000 committed Feb 4, 2020
1 parent de90f00 commit 8e2fd6d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 30 deletions.
16 changes: 2 additions & 14 deletions src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ impl<S: Storage + Clone> WickDB<S> {
let db = self.inner.clone();
thread::spawn(move || {
while let Ok(()) = db.do_compaction.1.recv() {
dbg!("receive compaction");
if db.is_shutting_down.load(Ordering::Acquire) {
// No more background work when shutting down
break;
Expand All @@ -338,7 +337,6 @@ impl<S: Storage + Clone> WickDB<S> {
// so reschedule another compaction if needed
let current = db.versions.lock().unwrap().current();
db.maybe_schedule_compaction(current);
dbg!("notify compaction finished");
db.background_work_finished_signal.notify_all();
}
});
Expand Down Expand Up @@ -451,9 +449,7 @@ impl<S: Storage + Clone + 'static> DBImpl<S> {
}
}
}
dbg!("nothing in memtable");
let current = self.versions.lock().unwrap().current();
dbg!(self.background_compaction_scheduled.load(Ordering::Acquire));
let (value, seek_stats) = current.get(options, lookup_key, &self.table_cache)?;
if current.update_stats(seek_stats) {
self.maybe_schedule_compaction(current)
Expand Down Expand Up @@ -816,7 +812,6 @@ impl<S: Storage + Clone + 'static> DBImpl<S> {
*im_mem = Some(memtable);
force = false; // do not force another compaction if have room
}
dbg!("immutable rotate");
self.maybe_schedule_compaction(versions.current());
}
}
Expand Down Expand Up @@ -939,10 +934,8 @@ impl<S: Storage + Clone + 'static> DBImpl<S> {
// This is a sync function call
fn background_compaction(&self) {
if self.im_mem.read().unwrap().is_some() {
dbg!("compact memtable");
// minor compaction
self.compact_mem_table();
dbg!("compact memtable complete");
} else {
let mut is_manual = false;
let mut versions = self.versions.lock().unwrap();
Expand Down Expand Up @@ -1247,7 +1240,6 @@ impl<S: Storage + Clone + 'static> DBImpl<S> {
{
// No work needs to be done
} else {
dbg!("send compaction signal");
self.background_compaction_scheduled
.store(true, Ordering::Release);
if let Err(e) = self.do_compaction.0.send(()) {
Expand Down Expand Up @@ -1703,21 +1695,17 @@ mod tests {
opt.write_buffer_size = 100000; // Small write buffer
opt
}).into_iter().enumerate() {
dbg!(i);
t.assert_put_get("foo", "v1");
let r = t.db.subscribe_compaction_complete();
// block `flush()`
t.store.delay_data_sync.store(true, Ordering::Release);
dbg!("k1");
t.put("k1", &"x".repeat(100000)).unwrap(); // fill memtable
assert_eq!("v1", dbg!(t.get("foo", None)).unwrap()); // "v1" on immutable table
dbg!("k2");
assert_eq!("v1", t.get("foo", None).unwrap()); // "v1" on immutable table
t.put("k2", &"y".repeat(100000)).unwrap(); // trigger compaction
// Waiting for compaction finish
r.recv().unwrap();
// Try to retrieve key "foo" from level 0 files
assert_eq!("v1", dbg!(t.get("foo", None)).unwrap()); // "v1" on level0 files
dbg!("end");
assert_eq!("v1", t.get("foo", None).unwrap()); // "v1" on level0 files
}
}
}
4 changes: 0 additions & 4 deletions src/sstable/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,11 @@ impl<C: Comparator> Iterator for BlockIterator<C> {
// linear search (with restart block) for first key >= target
// if all the keys > target, we seek to the start
// if all the keys < target, we seek to the last
dbg!(&self.current);
self.seek_to_restart_point(left);
dbg!(&self.current);
loop {
if !self.parse_block_entry() {
return;
}
dbg!(target);
dbg!(self.key.as_slice());
match self.cmp.compare(self.key.as_slice(), target) {
Ordering::Less => {}
_ => return,
Expand Down
12 changes: 0 additions & 12 deletions src/sstable/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ impl<F: File> Table<F> {
// If we don't add block into the cache and use `b.iter`
// the `Slice` returns by `iter.key()` may cause UB
if options.fill_cache {
dbg!("add block in block_cache");
cache.insert(cache_key_buffer, b, charge);
}
iter
Expand Down Expand Up @@ -188,23 +187,12 @@ impl<F: File> Table<F> {
if maybe_contained {
let (data_block_handle, _) = BlockHandle::decode_from(handle_val.as_slice())?;
let mut block_iter = self.block_reader(cmp, data_block_handle, options)?;
dbg!("seek key in data block");
block_iter.seek(key);
if block_iter.valid() {
dbg!(unsafe{block_iter.key().as_ptr().read()});
dbg!(block_iter.value());
<<<<<<< HEAD
return Ok(Some(block_iter));
=======
// FIXME: BlockIterator will be dropped after return. The `block_iter.key()` will cause UB!
return Ok(Some((block_iter.key(), block_iter.value())));
>>>>>>> some dbg
}
dbg!("no key found in data block");
block_iter.seek_to_first();
while block_iter.valid() {
dbg!(block_iter.key());
dbg!(block_iter.value());
block_iter.next();
}
block_iter.status()?;
Expand Down

0 comments on commit 8e2fd6d

Please sign in to comment.