diff options
author | Alex <alex@adnab.me> | 2024-03-12 10:45:57 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2024-03-12 10:45:57 +0000 |
commit | 81191d2d92e58ff82ace0f4d82b275c157673ade (patch) | |
tree | 53396e8ddbb94c4cc2f7f037a66c12a3c125c22f /src/db/lib.rs | |
parent | 2128b5febd97eb6c95e3bdd380dcba39b860c0e3 (diff) | |
parent | 2795b53b8b3ebd162df6b0244b73889e72f67ce0 (diff) | |
download | garage-81191d2d92e58ff82ace0f4d82b275c157673ade.tar.gz garage-81191d2d92e58ff82ace0f4d82b275c157673ade.zip |
Merge pull request 'Remove Sled' (#767) from rm-sled into next-0.10
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/767
Diffstat (limited to 'src/db/lib.rs')
-rw-r--r-- | src/db/lib.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/db/lib.rs b/src/db/lib.rs index 0fb457ce..ff511b5f 100644 --- a/src/db/lib.rs +++ b/src/db/lib.rs @@ -3,13 +3,9 @@ extern crate tracing; #[cfg(feature = "lmdb")] pub mod lmdb_adapter; -#[cfg(feature = "sled")] -pub mod sled_adapter; #[cfg(feature = "sqlite")] pub mod sqlite_adapter; -pub mod counted_tree_hack; - pub mod open; #[cfg(test)] @@ -55,6 +51,7 @@ pub type Result<T> = std::result::Result<T, Error>; pub struct TxOpError(pub(crate) Error); pub type TxOpResult<T> = std::result::Result<T, TxOpError>; +#[derive(Debug)] pub enum TxError<E> { Abort(E), Db(Error), @@ -189,10 +186,6 @@ impl Tree { pub fn len(&self) -> Result<usize> { self.0.len(self.1) } - #[inline] - pub fn fast_len(&self) -> Result<Option<usize>> { - self.0.fast_len(self.1) - } #[inline] pub fn first(&self) -> Result<Option<(Value, Value)>> { @@ -282,6 +275,11 @@ impl<'a> Transaction<'a> { pub fn remove<T: AsRef<[u8]>>(&mut self, tree: &Tree, key: T) -> TxOpResult<Option<Value>> { self.tx.remove(tree.1, key.as_ref()) } + /// Clears all values in a tree + #[inline] + pub fn clear(&mut self, tree: &Tree) -> TxOpResult<()> { + self.tx.clear(tree.1) + } #[inline] pub fn iter(&self, tree: &Tree) -> TxOpResult<TxValueIter<'_>> { @@ -328,9 +326,6 @@ pub(crate) trait IDb: Send + Sync { fn get(&self, tree: usize, key: &[u8]) -> Result<Option<Value>>; fn len(&self, tree: usize) -> Result<usize>; - fn fast_len(&self, _tree: usize) -> Result<Option<usize>> { - Ok(None) - } fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<Option<Value>>; fn remove(&self, tree: usize, key: &[u8]) -> Result<Option<Value>>; @@ -361,6 +356,7 @@ pub(crate) trait ITx { fn insert(&mut self, tree: usize, key: &[u8], value: &[u8]) -> TxOpResult<Option<Value>>; fn remove(&mut self, tree: usize, key: &[u8]) -> TxOpResult<Option<Value>>; + fn clear(&mut self, tree: usize) -> TxOpResult<()>; fn iter(&self, tree: usize) -> TxOpResult<TxValueIter<'_>>; fn iter_rev(&self, tree: usize) -> TxOpResult<TxValueIter<'_>>; |