From 833ade0fb10f97a48d4515e3330a0b84300779b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Blankfors?= Date: Tue, 29 Oct 2024 09:30:47 +0100 Subject: [PATCH] feat: Implement multi-get for more backends --- crates/fuel-core/src/state/data_source.rs | 8 ++++++++ crates/fuel-core/src/state/generic_database.rs | 8 ++++++++ crates/fuel-core/src/state/iterable_key_value_view.rs | 8 ++++++++ crates/fuel-core/src/state/key_value_view.rs | 9 +++++++++ crates/storage/src/structured_storage.rs | 8 ++++++++ 5 files changed, 41 insertions(+) diff --git a/crates/fuel-core/src/state/data_source.rs b/crates/fuel-core/src/state/data_source.rs index 10ff17b5046..dd861ea2ac4 100644 --- a/crates/fuel-core/src/state/data_source.rs +++ b/crates/fuel-core/src/state/data_source.rs @@ -64,6 +64,14 @@ where self.data.get(key, column) } + fn get_batch<'a>( + &'a self, + keys: BoxedIter<'a, Vec>, + column: Self::Column, + ) -> BoxedIter<'a, StorageResult>> { + self.data.get_batch(keys, column) + } + fn read( &self, key: &[u8], diff --git a/crates/fuel-core/src/state/generic_database.rs b/crates/fuel-core/src/state/generic_database.rs index ee82958abc9..a71870bc405 100644 --- a/crates/fuel-core/src/state/generic_database.rs +++ b/crates/fuel-core/src/state/generic_database.rs @@ -134,6 +134,14 @@ where KeyValueInspect::get(&self.storage, key, column) } + fn get_batch<'a>( + &'a self, + keys: BoxedIter<'a, Vec>, + column: Self::Column, + ) -> BoxedIter<'a, StorageResult>> { + KeyValueInspect::get_batch(&self.storage, keys, column) + } + fn read( &self, key: &[u8], diff --git a/crates/fuel-core/src/state/iterable_key_value_view.rs b/crates/fuel-core/src/state/iterable_key_value_view.rs index 40ab3483ede..4b739967735 100644 --- a/crates/fuel-core/src/state/iterable_key_value_view.rs +++ b/crates/fuel-core/src/state/iterable_key_value_view.rs @@ -63,6 +63,14 @@ where self.0.get(key, column) } + fn get_batch<'a>( + &'a self, + keys: BoxedIter<'a, Vec>, + column: Self::Column, + ) -> BoxedIter<'a, StorageResult>> { + self.0.get_batch(keys, column) + } + fn read( &self, key: &[u8], diff --git a/crates/fuel-core/src/state/key_value_view.rs b/crates/fuel-core/src/state/key_value_view.rs index 9e70037fc21..84d99f7be79 100644 --- a/crates/fuel-core/src/state/key_value_view.rs +++ b/crates/fuel-core/src/state/key_value_view.rs @@ -1,4 +1,5 @@ use fuel_core_storage::{ + iter::BoxedIter, kv_store::{ KeyValueInspect, StorageColumn, @@ -50,6 +51,14 @@ where self.0.get(key, column) } + fn get_batch<'a>( + &'a self, + keys: BoxedIter<'a, Vec>, + column: Self::Column, + ) -> BoxedIter<'a, StorageResult>> { + self.0.get_batch(keys, column) + } + fn read( &self, key: &[u8], diff --git a/crates/storage/src/structured_storage.rs b/crates/storage/src/structured_storage.rs index 5fb3de982b7..a58b51ebe42 100644 --- a/crates/storage/src/structured_storage.rs +++ b/crates/storage/src/structured_storage.rs @@ -146,6 +146,14 @@ where self.inner.get(key, column) } + fn get_batch<'a>( + &'a self, + keys: BoxedIter<'a, Vec>, + column: Self::Column, + ) -> BoxedIter<'a, StorageResult>> { + self.inner.get_batch(keys, column) + } + fn read( &self, key: &[u8],