VSDB is a 'Git' in the form of a KV database.
Based on the powerful version control function of VSDB, you can easily give your data structure the ability to version management.
Make everything versioned !!
Vecx
just like Vec
Mapx
just like HashMap
MapxOrd
just like BTreeMap
Suppose you have a great algorithm like this:
rust
struct GreatAlgo {
a: Vec<...>,
b: BTreeMap<...>,
c: u128,
d: HashMap<...>,
e: ...
}
Simply replace the original structure with the corresponding VSDB data structure,
and your algorithm get the powerful version control ability at once!
```rust
struct GreatAlgo {
a: VecxVs<...>,
b: MapxOrdVs<...>,
c: OrphanVs
impl GreatAlgo { fn versioncreate(&self, name: &str) { self.a.versioncreate(VersionName(name)).unwrap(); self.b.versioncreate(VersionName(name)).unwrap(); self.c.versioncreate(VersionName(name)).unwrap(); self.d.versioncreate(VersionName(name)).unwrap(); ... } fn branchcreate(&self, name: &str) { self.a.branchcreate(BranchName(name)).unwrap(); self.b.branchcreate(BranchName(name)).unwrap(); self.c.branchcreate(BranchName(name)).unwrap(); self.d.branchcreate(BranchName(name)).unwrap(); ... } ... } ```
Some complete examples:
- Versioned examples:
- Unversioned examples:
sled_engine
, use sled as the backend database
rocks_engine
, use rocksdb as the backedn database
cbor_ende
, use cbor as the en/de
coder
bcs_ende
, use bcs as the en/de
coder
Based on the underlying one-dimensional linear storage structure (native kv-database, such as sled/rocksdb, etc.), multiple different namespaces are divided, and then abstract each dimension in the multi-dimensional logical structure based on these divided namespaces.
In the category of kv-database, namespaces can be expressed as different key ranges, or different key prefix.
This is the same as expressing complex data structures in computer memory(the memory itself is just a one-dimensional linear structure).
User data will be divided into two dimensions: 'branch' and 'version', the functions of the 'basic' category are stateless, and the functions of the 'versioned' category are stateful. In the internal implementation, each stateful function is implemented based on its corresponding stateless function, all stateful data has two additional identification dimensions ('branch' and 'version'), somewhat like the logic in Git. Stateless functions do not have the feature of 'version' management, but they have higher performance.