diff --git a/src/pdata/space_map_metadata.rs b/src/pdata/space_map_metadata.rs index be55fc3..9002ca0 100644 --- a/src/pdata/space_map_metadata.rs +++ b/src/pdata/space_map_metadata.rs @@ -77,7 +77,7 @@ fn adjust_counts( let nr_free = ie.nr_free - (end - begin) as u32; // Read the bitmap - let bitmap_block = w.engine.read(ie.blocknr)?; + let bitmap_block = w.read(ie.blocknr)?; let (_, mut bitmap) = Bitmap::unpack(bitmap_block.get_data())?; // Update all the entries diff --git a/src/write_batcher.rs b/src/write_batcher.rs index b6e7a34..2300c87 100644 --- a/src/write_batcher.rs +++ b/src/write_batcher.rs @@ -109,6 +109,14 @@ impl WriteBatcher { pub fn write(&mut self, b: Block, kind: checksum::BT) -> Result<()> { checksum::write_checksum(&mut b.get_data(), kind)?; + for blk in self.queue.iter().rev() { + if blk.loc == b.loc { + // write hit + blk.get_data().copy_from_slice(b.get_data()); + return Ok(()); + } + } + if self.queue.len() == self.batch_size { let mut tmp = Vec::new(); std::mem::swap(&mut tmp, &mut self.queue);