diff options
author | Alex <alex@adnab.me> | 2024-09-10 09:06:29 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2024-09-10 09:06:29 +0000 |
commit | 586957b4b7261b43e7820d7193516153201b4954 (patch) | |
tree | ff57ef1a40dc5bd888a6fdfe36dd8cd119626e61 /src/db/sqlite_adapter.rs | |
parent | 8d2bb4afeba6a90ba12a41144246e3b08eac70f8 (diff) | |
parent | 8062ec7b4b6115e6158ec1b5523b4bd8dc0185be (diff) | |
download | garage-586957b4b7261b43e7820d7193516153201b4954.tar.gz garage-586957b4b7261b43e7820d7193516153201b4954.zip |
Merge pull request 'KV: don't retrieve values for write ops' (#873) from marvinj97/garage:perf/kv/insert-no-return into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/873
Reviewed-by: Alex <alex@adnab.me>
Diffstat (limited to 'src/db/sqlite_adapter.rs')
-rw-r--r-- | src/db/sqlite_adapter.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs index a91b9011..5a142117 100644 --- a/src/db/sqlite_adapter.rs +++ b/src/db/sqlite_adapter.rs @@ -169,7 +169,7 @@ impl IDb for SqliteDb { } } - fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<Option<Value>> { + fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<()> { let tree = self.get_tree(tree)?; let db = self.db.get()?; let lock = self.write_lock.lock(); @@ -184,23 +184,18 @@ impl IDb for SqliteDb { assert_eq!(n, 1); drop(lock); - Ok(old_val) + Ok(()) } - fn remove(&self, tree: usize, key: &[u8]) -> Result<Option<Value>> { + fn remove(&self, tree: usize, key: &[u8]) -> Result<()> { let tree = self.get_tree(tree)?; let db = self.db.get()?; let lock = self.write_lock.lock(); - let old_val = self.internal_get(&db, &tree, key)?; - - if old_val.is_some() { - let n = db.execute(&format!("DELETE FROM {} WHERE k = ?1", tree), params![key])?; - assert_eq!(n, 1); - } + let n = db.execute(&format!("DELETE FROM {} WHERE k = ?1", tree), params![key])?; drop(lock); - Ok(old_val) + Ok(()) } fn clear(&self, tree: usize) -> Result<()> { |