aboutsummaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/db')
-rw-r--r--src/db/Cargo.toml10
-rw-r--r--src/db/lib.rs7
-rw-r--r--src/db/lmdb_adapter.rs4
-rw-r--r--src/db/sqlite_adapter.rs4
4 files changed, 20 insertions, 5 deletions
diff --git a/src/db/Cargo.toml b/src/db/Cargo.toml
index 82cf49dc..95bde6d5 100644
--- a/src/db/Cargo.toml
+++ b/src/db/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "garage_db"
-version = "0.8.0"
+version = "0.8.1"
authors = ["Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "AGPL-3.0"
@@ -19,18 +19,18 @@ required-features = ["cli"]
[dependencies]
err-derive = "0.3"
hexdump = "0.1"
-tracing = "0.1.30"
+tracing = "0.1"
heed = { version = "0.11", default-features = false, features = ["lmdb"], optional = true }
-rusqlite = { version = "0.27", optional = true }
+rusqlite = { version = "0.28", optional = true }
sled = { version = "0.34", optional = true }
# cli deps
-clap = { version = "3.1.18", optional = true, features = ["derive", "env"] }
+clap = { version = "4.1", optional = true, features = ["derive", "env"] }
pretty_env_logger = { version = "0.4", optional = true }
[dev-dependencies]
-mktemp = "0.4"
+mktemp = "0.5"
[features]
default = [ "sled" ]
diff --git a/src/db/lib.rs b/src/db/lib.rs
index d96586be..11cae4e3 100644
--- a/src/db/lib.rs
+++ b/src/db/lib.rs
@@ -181,6 +181,10 @@ 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)>> {
@@ -323,6 +327,9 @@ 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>>;
diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs
index c036c990..31956612 100644
--- a/src/db/lmdb_adapter.rs
+++ b/src/db/lmdb_adapter.rs
@@ -121,6 +121,10 @@ impl IDb for LmdbDb {
Ok(tree.len(&tx)?.try_into().unwrap())
}
+ fn fast_len(&self, tree: usize) -> Result<Option<usize>> {
+ Ok(Some(self.len(tree)?))
+ }
+
fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<Option<Value>> {
let tree = self.get_tree(tree)?;
let mut tx = self.db.write_txn()?;
diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs
index 886fda6e..63b4506e 100644
--- a/src/db/sqlite_adapter.rs
+++ b/src/db/sqlite_adapter.rs
@@ -144,6 +144,10 @@ impl IDb for SqliteDb {
}
}
+ fn fast_len(&self, tree: usize) -> Result<Option<usize>> {
+ Ok(Some(self.len(tree)?))
+ }
+
fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<Option<Value>> {
trace!("insert {}: lock db", tree);
let this = self.0.lock().unwrap();