Skip to content
Snippets Groups Projects
Commit 6fe0ea05 authored by Jason Volk's avatar Jason Volk Committed by 🥺
Browse files

add remove_batch with transaction to database abstraction.


adjusted to make building sqlite happy again

Signed-off-by: default avatarJason Volk <jason@zemos.net>
Signed-off-by: default avatarstrawberry <strawberry@puppygock.gay>
parent ba03d558
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,10 @@ fn multi_get(
fn remove(&self, key: &[u8]) -> Result<()>;
#[allow(dead_code)]
#[cfg(feature = "rocksdb")]
fn remove_batch(&self, _iter: &mut dyn Iterator<Item = Vec<u8>>) -> Result<()> { unimplemented!() }
fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = (Vec<u8>, Vec<u8>)> + 'a>;
fn iter_from<'a>(&'a self, from: &[u8], backwards: bool) -> Box<dyn Iterator<Item = (Vec<u8>, Vec<u8>)> + 'a>;
......
......@@ -251,6 +251,18 @@ fn remove(&self, key: &[u8]) -> Result<()> {
Ok(self.db.rocks.delete_cf_opt(&self.cf(), key, &writeoptions)?)
}
fn remove_batch(&self, iter: &mut dyn Iterator<Item = Vec<u8>>) -> Result<()> {
let writeoptions = rust_rocksdb::WriteOptions::default();
let mut batch = WriteBatchWithTransaction::<false>::default();
for key in iter {
batch.delete_cf(&self.cf(), key);
}
Ok(self.db.rocks.write_opt(batch, &writeoptions)?)
}
fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = (Vec<u8>, Vec<u8>)> + 'a> {
let mut readoptions = rust_rocksdb::ReadOptions::default();
readoptions.set_total_order_seek(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment