Expand description
This module is used in the Linera protocol to map complex data structures onto a
key-value store. The central notion is a views::View
which can be loaded from storage, modified in memory, and then committed (i.e. the changes are atomically persisted in storage).
The package provides essentially two functionalities:
- An abstraction to access databases.
- Several containers named views for storing data modeled on classical ones.
See DESIGN.md for more details.
§The supported databases.
The databases supported are of the NoSQL variety and they are key-value stores.
We provide support for the following databases:
MemoryDatabaseis using the memoryRocksDbDatabaseis a disk-based key-value storeDynamoDbDatabaseis the AWS-based DynamoDB service.ScyllaDbDatabaseis a cloud-based Cassandra-compatible database.StorageServiceDatabaseis a gRPC-based storage that uses either memory or RocksDB. It is available inlinera-storage-service.
The corresponding trait in the code is the crate::store::KeyValueDatabase.
as well as crate::store::KeyValueStore.
The latter trait decomposes into a store::ReadableKeyValueStore
and a store::WritableKeyValueStore.
A context is the combination of a client and a base key (of type Vec<u8>).
§Views.
A view is a container whose data lies in one of the above-mentioned databases.
When the container is modified the modification lies first in the view before
being committed to the database. In technical terms, a view implements the trait View.
The specific functionalities of the trait View are the following:
contextfor obtaining a reference to the storage context of the view.loadfor loading the view from a specific context.rollbackfor canceling all modifications that were not committed thus far.clearfor clearing the view, in other words for reverting it to its default state.flushfor persisting the changes to storage.
The following views implement the View trait:
RegisterViewimplements the storing of a single data.LogViewimplements a log, which is a list of entries that can be expanded.QueueViewimplements a queue, which is a list of entries that can be expanded and reduced.MapViewimplements a map with keys and values.SetViewimplements a set with keys.CollectionViewimplements a map whose values are views themselves.ReentrantCollectionViewimplements a map for which different keys can be accessed independently.ViewContainer<C>implements aKeyValueStoreand is used internally.
The LogView can be seen as an analog of VecDeque while MapView is an analog of BTreeMap.
Re-exports§
pub use backends::dynamo_db;pub use backends::metering;pub use backends::rocks_db;pub use backends::scylla_db;pub use backends::journaling;pub use backends::lru_caching;pub use backends::memory;pub use backends::value_splitting;pub use views::bucket_queue_view;pub use views::collection_view;pub use views::hashable_wrapper;pub use views::historical_hash_wrapper;pub use views::key_value_store_view;pub use views::log_view;pub use views::map_view;pub use views::queue_view;pub use views::reentrant_collection_view;pub use views::register_view;pub use views::set_view;
Modules§
- backends
- Backend implementing the
crate::store::KeyValueStoretrait. - batch
- The definition of the batches for writing in the database. A set of functionalities for building batches to be written into the database. A batch can contain three kinds of operations on a key/value store:
- common
- Common definitions used for views and backends. This provides some common code for the linera-views.
- context
- The
Contexttrait and related definitions. - lru_
prefix_ cache - Definitions for the LRU cache. An LRU cache that supports prefix-search APIs.
- metrics
- Support for metrics.
- random
- Functions for random generation
- store
- The
KeyValueDatabaseandKeyValueStoretraits and related definitions. This provides the trait definitions for the stores. - test_
utils - Helper types for tests.
- views
- Elementary data-structures implementing the
views::Viewtrait.
Enums§
- View
Error - Main error type for the crate.