Skip to content

Commit 0d549f1

Browse files
committed
Introduce the Small KeyValue store
1 parent c1d1ec4 commit 0d549f1

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
@@ -12,6 +12,7 @@ repository.workspace = true
1212
version.workspace = true
1313

1414
[features]
15+
smallkeyvaluestoreview = []
1516
test = ["tokio/macros", "linera-base/test", "linera-views/test", "proptest"]
1617
revm = [
1718
"dep:revm",

linera-execution/src/execution.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use linera_base::{
1313
};
1414
use linera_views::{
1515
context::Context,
16-
key_value_store_view::KeyValueStoreView,
1716
map_view::MapView,
1817
reentrant_collection_view::HashedReentrantCollectionView,
1918
views::{ClonableView, ReplaceContext, View},
@@ -44,7 +43,18 @@ pub struct ExecutionStateView<C> {
4443
/// System application.
4544
pub system: SystemExecutionStateView<C>,
4645
/// User applications.
47-
pub users: HashedReentrantCollectionView<C, ApplicationId, KeyValueStoreView<C>>,
46+
#[cfg(not(feature = "smallkeyvaluestoreview"))]
47+
pub users: HashedReentrantCollectionView<
48+
C,
49+
ApplicationId,
50+
linera_views::small_key_value_store_view::SmallKeyValueStoreView<C>,
51+
>,
52+
#[cfg(feature = "smallkeyvaluestoreview")]
53+
pub users: HashedReentrantCollectionView<
54+
C,
55+
ApplicationId,
56+
linera_views::key_value_store_view::KeyValueStoreView<C>,
57+
>,
4858
/// The number of events in the streams that this chain is writing to.
4959
pub stream_event_counts: MapView<C, StreamId, u32>,
5060
}

linera-views/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub use backends::scylla_db;
117117
pub use backends::{journaling, lru_caching, memory, value_splitting};
118118
pub use views::{
119119
bucket_queue_view, collection_view, hashable_wrapper, key_value_store_view, log_view, map_view,
120-
queue_view, reentrant_collection_view, register_view, set_view,
120+
queue_view, reentrant_collection_view, register_view, set_view, small_key_value_store_view,
121121
};
122122
/// Re-exports used by the derive macros of this library.
123123
#[doc(hidden)]

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)