【大家的项目】VSDB: 一个 KV database 版的 Git

这是群友的项目。

在诸如区块链之类的分布式领域,有重大价值。

VSDB

https://crates.io/crates/vsdb

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 !!

Highlights

  • Support Git-like verison operations, such as:

    • Create countless branches and merge them to their parents

    • Rolling back a 'branch' to a specified historical 'version'

    • Querying the historical value of a key on the specified 'branch'

  • Most APIs is similar as the coresponding data structures in the standard library

    • Use Vecx just like Vec

    • Use Mapx just like HashMap

    • Use MapxOrd just like BTreeMap

  • ...

Examples

Suppose you have a great algorithm like this:

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!

struct GreatAlgo {
    a: VecxVs<...>,
    b: MapxOrdVs<...>,
    c: OrphanVs<u128>,
    d: MapxVs<...>,
    e: ...
}

impl GreatAlgo {
    fn version_create(&self, name: &str) {
        self.a.version_create(VersionName(name)).unwrap();
        self.b.version_create(VersionName(name)).unwrap();
        self.c.version_create(VersionName(name)).unwrap();
        self.d.version_create(VersionName(name)).unwrap();
        ...
    }
    fn branch_create(&self, name: &str) {
        self.a.branch_create(BranchName(name)).unwrap();
        self.b.branch_create(BranchName(name)).unwrap();
        self.c.branch_create(BranchName(name)).unwrap();
        self.d.branch_create(BranchName(name)).unwrap();
        ...
    }
    ...
}

Some complete examples:

  • Versioned examples:

    • Simple blockchain

    • Operations one by one

  • Unversioned examples:

    • Simple web server

    • Operations one by one

Compilation features

  • [defaultsled_engine, use sled as the backend database

    • Faster compilation speed

    • Support for compiling into a statically linked binary

  • rocks_engine, use rocksdb as the backedn database

    • Faster running speed

    • Can not be compiled into a statically linked binary

  • [defaultcbor_ende, use cbor as the en/decoder

    • Faster running speed

  • bcs_ende, use bcs as the en/decoder

    • Created by the libre project of Facebook

    • Security reinforcement for blockchain scenarios

Low-level design

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值