Skip to content

Commit 134a3f8

Browse files
committed
Introduce the Small KeyValue store
1 parent a5c2afa commit 134a3f8

File tree

7 files changed

+769
-9
lines changed

7 files changed

+769
-9
lines changed

linera-execution/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ version.workspace = true
1515
workspace = true
1616

1717
[features]
18+
smallkeyvaluestoreview = []
1819
test = ["tokio/macros", "linera-base/test", "linera-views/test", "proptest"]
1920
revm = [
2021
"dep:revm",

linera-execution/src/execution.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use linera_base::{
1111
};
1212
use linera_views::{
1313
context::Context,
14-
key_value_store_view::KeyValueStoreView,
1514
reentrant_collection_view::HashedReentrantCollectionView,
1615
views::{ClonableView, ReplaceContext, View},
1716
};
@@ -41,7 +40,18 @@ pub struct ExecutionStateView<C> {
4140
/// System application.
4241
pub system: SystemExecutionStateView<C>,
4342
/// User applications.
44-
pub users: HashedReentrantCollectionView<C, ApplicationId, KeyValueStoreView<C>>,
43+
#[cfg(not(feature = "smallkeyvaluestoreview"))]
44+
pub users: HashedReentrantCollectionView<
45+
C,
46+
ApplicationId,
47+
linera_views::small_key_value_store_view::SmallKeyValueStoreView<C>,
48+
>,
49+
#[cfg(feature = "smallkeyvaluestoreview")]
50+
pub users: HashedReentrantCollectionView<
51+
C,
52+
ApplicationId,
53+
linera_views::key_value_store_view::KeyValueStoreView<C>,
54+
>,
4555
}
4656

4757
impl<C: Context, C2: Context> ReplaceContext<C2> for ExecutionStateView<C> {

linera-views/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,5 @@ pub use generic_array;
125125
pub use sha3;
126126
pub use views::{
127127
bucket_queue_view, collection_view, hashable_wrapper, key_value_store_view, log_view, map_view,
128-
queue_view, reentrant_collection_view, register_view, set_view,
128+
queue_view, reentrant_collection_view, register_view, set_view, small_key_value_store_view,
129129
};

linera-views/src/views/key_value_store_view.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,12 @@ impl<C: Context> KeyValueStoreView<C> {
396396
/// # use linera_views::views::View;
397397
/// # let context = MemoryContext::new_for_testing(());
398398
/// let mut view = KeyValueStoreView::load(context).await.unwrap();
399-
/// let total_size = view.total_size();
399+
/// let total_size = view.total_size().unwrap();
400400
/// assert_eq!(total_size, SizeData::default());
401401
/// # })
402402
/// ```
403-
pub fn total_size(&self) -> SizeData {
404-
self.total_size
403+
pub fn total_size(&self) -> Result<SizeData, ViewError> {
404+
Ok(self.total_size)
405405
}
406406

407407
/// Applies the function f over all indices. If the function f returns

linera-views/src/views/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ pub mod reentrant_collection_view;
4242
/// The implementation of a key-value store view.
4343
pub mod key_value_store_view;
4444

45+
/// The implementation of a key-value store view using a single BTreeMap.
46+
pub mod small_key_value_store_view;
47+
4548
/// Wrapping a view to compute a hash.
4649
pub mod hashable_wrapper;
4750

0 commit comments

Comments
 (0)