diff --git a/README-zh_CN.md b/README-zh_CN.md index 0391b00..710607d 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -1,99 +1,155 @@
- + -

Txn

+

SkipDB & Watermark & Txn

-Generic transaction manager implementations for developing MVCC and ACID databases. +This repository the implementation: -[github][Github-url] -LoC -[Build][CI-url] -[codecov][codecov-url] +1. Generic optimistic transaction manger, which supports concurrent execution of transactions, providing serializable snapshot isolation, avoiding write skews. +2. An atomicity, consistency, isolation, MVCC and WASM friendly in-memory database based on the transaction manager. -[docs.rs][doc-url] -[crates.io][crates-url] -[crates.io][crates-url] -license +[github][Github-url] +LoC +[Build][CI-url] +[codecov][codecov-url] +[docs.rs][doc-url] +LoC +[crates.io][crates-url] +[crates.io][crates-url] -[English][en-url] | 简体中文 +[docs.rs][async-doc-url] +LoC +[crates.io][async-crates-url] +[crates.io][async-crates-url] + +[docs.rs][txn-doc-url] +LoC +[crates.io][txn-crates-url] +[crates.io][txn-crates-url] + +[docs.rs][async-txn-doc-url] +LoC +[crates.io][async-txn-crates-url] +[crates.io][async-txn-crates-url] + +[docs.rs][wmark-doc-url] +LoC +[crates.io][wmark-crates-url] +[crates.io][wmark-crates-url] + +license + + +English | [简体中文][zh-cn-url]
-## Installation +## Introduction + +This repository contains a transaction framework (`async-txn` and `txn`) based on optimistic concurrency control, which is inspired by [`foundationdb`'s paper](https://www.foundationdb.org/files/fdb-paper.pdf) and [`badger`](https://github.com/dgraph-io/badger). + +This repository contains two kinds of in-memory key-value database which supports both async (`async-skipdb`) and sync (`skipdb`): + +1. `SerializableDb` + + Supports both concurrent execution of full serializable snapshot isolation transactions and optimistic concurrency control transactions. + + Transactions are created by `SerializableDb::serializable_write` can handle all kinds of write skew correctly. + + Transactions are created by `SerializableDb::optimistic_write` can handle all kinds of direct dependent write skew, but cannot handle all kinds of indirect dependent write skew e.g. https://wiki.postgresql.org/wiki/SSI#Intersecting_Data. + +2. `OptimisticDb` + + Only support oncurrent execution of optimistic concurrency control, which means the write transaction cannot detect all kinds of write skew. -```toml -[dependencies] -crates = "0.1" -``` + All kinds of direct dependent write skew can be handled correctly, but cannot handle all kinds of indirect dependent write skew e.g. https://wiki.postgresql.org/wiki/SSI#Intersecting_Data. -## Example +### Features -```rust -use crates::example; +- Atomicity, Consistency, Isolation, MVCC, concurrent safe and almost lock-free. +- No extra allocation and copy, there is no `Arc` wrapper for both key and value stored in the database, which means that users provide `K` and `V`, and database store `K` and `V` directly. +- Zero-copy and in-place compaction, which means there is no copy, no extra allocation when compacting. +- Concurrent execution of transactions, providing serializable snapshot isolation, avoiding write skews. +- Both read transaction and write transaction are `Send + Sync + 'static`, which means you do not need to handle annoying lifetime problem anymore. +- Lock-free and concurrent safe read transaction: the read transaction is totally concurrent safe and can be shared in multiple threads, there is no lock in read transaction. +- `BTreeMap` like user friendly API and all iterators implement `Iterator` trait, which means users use Rust powerful conbinators when iterating over the database. +- Async version is runtime agnostic, `tokio`, `async-std`, `smol`, `wasm-bindgen-futures` and any other async runtime. +- 100% safe, sets `[forbid(unsafe_code)]`. -fn main() { + +## Installation + +- For sync -} -``` + ```toml + [dependencies] + skipdb = "0.2" + ``` + +- For async + - `tokio` -## Tests + ```toml + [dependencies] + async-skipdb = { version = "0.2", features = ["tokio"] } + ``` + + - `async-std` + + ```toml + [dependencies] + async-skipdb = { version = "0.2", features = ["async-std"] } + ``` -- `test`: + - `smol` - ```sh - cargo test --all-features + ```toml + [dependencies] + async-skipdb = { version = "0.2", features = ["smol"] } ``` -- `miri`: + - `wasm-bindgen-futures` - ```sh - cargo miri test --all-features + ```toml + [dependencies] + async-skipdb = { version = "0.2", features = ["wasm"] } ``` -## Support Platforms - -| targets | status | -|:-----------------------------:|:---------:| -| aarch64-linux-android | ✅ | -| aarch64-unknown-linux-gnu | ✅ | -| aarch64-unknown-linux-musl | ✅ | -| i686-pc-windows-gnu | ✅ | -| i686-linux-android | ✅ | -| i686-unknown-linux-gnu | ✅ | -| mips64-unknown-linux-gnuabi64 | ✅ | -| powerpc64-unknown-linux-gnu | ✅ | -| riscv64gc-unknown-linux-gnu | ✅ | -| wasm32-unknown-unknown | ✅ | -| wasm32-unknown-emscripten | ✅ | -| x86_64-unknown-linux-gnu | ✅ | -| x86_64-pc-windows-gnu | ✅ | -| x86_64-linux-android | ✅ | - -## TODO (help wanted) - -- [x] Done -- [ ] WIP +## Examples + +Please see [skipdb](./skipdb/) or [async-skipdb](./async-skipdb). #### License -`txn` is under the terms of both the MIT license and the +`skipdb` is under the terms of both the MIT license and the Apache License (Version 2.0). See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT) for details. Copyright (c) 2024 Al Liu. -[Github-url]: https://github.com/al8n/crates/ -[CI-url]: https://github.com/al8n/crates/actions/workflows/ci.yml -[doc-url]: https://docs.rs/crates -[crates-url]: https://crates.io/crates/crates -[codecov-url]: https://app.codecov.io/gh/al8n/crates/ -[rustc-url]: https://github.com/rust-lang/rust/blob/master/RELEASES.md -[license-apache-url]: https://opensource.org/licenses/Apache-2.0 -[license-mit-url]: https://opensource.org/licenses/MIT -[en-url]: https://github.com/al8n/txn/tree/main/README.md +[Github-url]: https://github.com/al8n/skipdb/ +[CI-url]: https://github.com/al8n/skipdb/actions/workflows/ci.yml + +[doc-url]: https://docs.rs/skipdb +[crates-url]: https://crates.io/crates/skipdb + +[async-doc-url]: https://docs.rs/async-skipdb +[async-crates-url]: https://crates.io/crates/async-skipdb + +[wmark-doc-url]: https://docs.rs/wmark +[wmark-crates-url]: https://crates.io/crates/wmark + +[async-txn-doc-url]: https://docs.rs/async-txn +[async-txn-crates-url]: https://crates.io/async-txn + +[txn-doc-url]: https://docs.rs/txn +[txn-crates-url]: https://crates.io/txn + +[codecov-url]: https://app.codecov.io/gh/al8n/skipdb/ +[zh-cn-url]: https://github.com/al8n/skipdb/tree/main/README-zh_CN.md diff --git a/README.md b/README.md index e9cf44e..710607d 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ This repository contains two kinds of in-memory key-value database which support ```toml [dependencies] - skipdb = "0.1" + skipdb = "0.2" ``` - For async @@ -96,28 +96,28 @@ This repository contains two kinds of in-memory key-value database which support ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["tokio"] } + async-skipdb = { version = "0.2", features = ["tokio"] } ``` - `async-std` ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["async-std"] } + async-skipdb = { version = "0.2", features = ["async-std"] } ``` - `smol` ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["smol"] } + async-skipdb = { version = "0.2", features = ["smol"] } ``` - `wasm-bindgen-futures` ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["wasm"] } + async-skipdb = { version = "0.2", features = ["wasm"] } ``` ## Examples diff --git a/async-skipdb/Cargo.toml b/async-skipdb/Cargo.toml index f0aa42c..90d2e01 100644 --- a/async-skipdb/Cargo.toml +++ b/async-skipdb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-skipdb" -version = "0.2.0" +version = "0.2.1" rust-version.workspace = true edition.workspace = true repository.workspace = true diff --git a/async-skipdb/README-zh_CN.md b/async-skipdb/README-zh_CN.md index bd0b836..fe5c41d 100644 --- a/async-skipdb/README-zh_CN.md +++ b/async-skipdb/README-zh_CN.md @@ -62,28 +62,28 @@ This crate contains two kinds of in-memory key-value database: ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["tokio"] } + async-skipdb = { version = "0.2", features = ["tokio"] } ``` - `async-std` ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["async-std"] } + async-skipdb = { version = "0.2", features = ["async-std"] } ``` - `smol` ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["smol"] } + async-skipdb = { version = "0.2", features = ["smol"] } ``` - `wasm-bindgen-futures` ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["wasm"] } + async-skipdb = { version = "0.2", features = ["wasm"] } ``` ## Example diff --git a/async-skipdb/README.md b/async-skipdb/README.md index bd0b836..fe5c41d 100644 --- a/async-skipdb/README.md +++ b/async-skipdb/README.md @@ -62,28 +62,28 @@ This crate contains two kinds of in-memory key-value database: ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["tokio"] } + async-skipdb = { version = "0.2", features = ["tokio"] } ``` - `async-std` ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["async-std"] } + async-skipdb = { version = "0.2", features = ["async-std"] } ``` - `smol` ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["smol"] } + async-skipdb = { version = "0.2", features = ["smol"] } ``` - `wasm-bindgen-futures` ```toml [dependencies] - async-skipdb = { version = "0.1", features = ["wasm"] } + async-skipdb = { version = "0.2", features = ["wasm"] } ``` ## Example diff --git a/skipdb/Cargo.toml b/skipdb/Cargo.toml index 56e748d..d831829 100644 --- a/skipdb/Cargo.toml +++ b/skipdb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "skipdb" -version = "0.2.0" +version = "0.2.1" rust-version.workspace = true edition.workspace = true repository.workspace = true diff --git a/skipdb/README-zh_CN.md b/skipdb/README-zh_CN.md index eda4bee..59caa91 100644 --- a/skipdb/README-zh_CN.md +++ b/skipdb/README-zh_CN.md @@ -59,7 +59,7 @@ This crate contains two kinds of in-memory key-value database: ```toml [dependencies] -skipdb = "0.1" +skipdb = "0.2" ``` ## Example diff --git a/skipdb/README.md b/skipdb/README.md index eda4bee..59caa91 100644 --- a/skipdb/README.md +++ b/skipdb/README.md @@ -59,7 +59,7 @@ This crate contains two kinds of in-memory key-value database: ```toml [dependencies] -skipdb = "0.1" +skipdb = "0.2" ``` ## Example