Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
//! Abstracted database environment; `trait Env`.
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------- Import
|
2024-05-05 14:21:28 +00:00
|
|
|
use std::num::NonZeroUsize;
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
use crate::{
|
database: Resizes, Shutdown, Flushing (#68)
* error: add `NeedsResize`
accidently removed, was `MapFull` before.
We need this because we as the writer thread must
react to this error in order to resize.
The writer thread doesn't have access to `heed::Error`, but
`Runtime::Error`, so this variant must exist
* env/backend: add `MANUAL_RESIZE` and `resize()`
* heed: respect `ReadersFull`, comment errors
* free: add `resize_memory_map()`
* env: add `Env::current_map_size`
* service: add `resize_map()`
* database: make `Env` itself cheaply clonable + threadsafe
`heed::Env` already uses `Arc` internally, but `sanakirja` does
not, so abstract this at the `Env` level instead of wrapping
`ConcreteEnv` in `Arc` ourselves.
* service: `Arc<ConcreteEnv>` -> `ConcreteEnv: Clone`
* env: add `SYNCS_PER_TX`, `path()`, `shutdown()`
* database: add `src/service/state.rs`
* service: add to `state.rs`, add `DatabaseState` to readers/writer
* add `parking_lot`
Okay, turns out we need to take locks in
`database/src/service/state.rs`...
`std`'s lock fairness policies are not well defined and
depend on the OS implementation, `parking_lot` on the other hand
has a fairness policy which is important when the writer needs
the lock but readers keep pouring in, essentially never letting
the writer do stuff.
* state: use `crossbeam::atomic::AtomicCell`
We have crossbeam as a dep anyway.
* heed: `heed::Env` -> `Arc<RwLock<heed::Env>>`
* service: add reader shutdown handle, use `Select` for msgs
* service: remove `state.rs`
We don't need this, we will represent shutdowns with channel
messages and `Select`, and mutual exclusion with a `RwLock`.
* service: fix misc reader/writer stuff
* database: add `config.rs`
* service: use `ReaderThreads` when spawning readers
* service: impl `shutdown()` for readers/writer
* service: return `DatabaseReaderReceivers` on shutdown via `JoinHandle`
Solves the issue of unfortunately timed `Request`s
that come in _right_ as we are shutting down.
If we (Cuprate) drop the database channels too early the requesting
thread will probably panic as they probably use `.unwrap()`,
never expecting a channel failure.
Returning this structure containing all the channels allows the
final shutdown code to carry these channels until the very end
of the program, at which point, all threads exit - no panics.
* remove `parking_lot`
Could be used as the database mutual exclusion lock.
Needs to be tested against `std`.
* config: add `path`
* env: `path()` -> `config()`, backend: impl `Drop`
* `Arc<ConcreteEnv>`, shutdown `service` on channel disconnect
* backend: add `Config` to `ConcreteEnv`
* service: use `std::thread::Builder` for readers/writer
* config: `PathBuf` -> `Cow<'static, Path>`
* misc docs, remove `RuntimeError::ShuttingDown`
* service: init & shutdown docs
* heed: impl `Env::resize_map()`
* heed: impl `Env::current_map_size()`
* lib.rs: add example crate usage test
* heed: `RwLock` comment
* helper: add `cuprate_database_dir()`
* config: use `cuprate_database_dir()`
* lib.rs: TODO example test
* database: add `page_size`
The database memory map size must be a multiple of
the OS page size. Why doesn't `heed` re-expose this?
It calls it when checking anyway...
https://docs.rs/heed/0.20.0-alpha.9/src/heed/env.rs.html#772
* free: impl `resize_memory_map()`
* free: docs
* env: add `disk_size_bytes()`
* config: impl `From<$num>` for `ReaderThreads`
* move `fs`-related constants to `cuprate_helper::fs`
* docs
* add `resize.rs`, `ResizeAlgorithm`
* env: use `ResizeAlgorithm` in `resize_map()`
* TODO: account for LMDB reader limit
* resize: docs, add `page_size()`, impl `fixed_bytes()`
* resize: impl `percent()`
* resize: docs
* env: take `ResizeAlgorithm` by value (it impls `Copy`)
* heed: TODO for `MDB_MAP_FULL` & `MDB_MAP_RESIZED`
* config: `From<Into<usize>>` for `ReaderThreads`
Co-authored-by: Boog900 <boog900@tutanota.com>
* env: move mutual exclusion doc to backend
* free: update invariant doc
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/service/mod.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* fix `[allow(unused_imports)] // docs`
* move DB filename from `helper/` -> `database/`
* config: use `DATABASE_FILENAME`
* config: add `db_file_path()`
* lib: add non-`service` usage invariant docs
* table: seal `Table` trait, impl for all `crate::tables`
* fix docs
* fix docs pt.2
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-02-25 19:46:36 +00:00
|
|
|
config::Config,
|
2024-04-03 21:44:25 +00:00
|
|
|
database::{DatabaseIter, DatabaseRo, DatabaseRw},
|
2024-02-17 13:00:14 +00:00
|
|
|
error::{InitError, RuntimeError},
|
database: Resizes, Shutdown, Flushing (#68)
* error: add `NeedsResize`
accidently removed, was `MapFull` before.
We need this because we as the writer thread must
react to this error in order to resize.
The writer thread doesn't have access to `heed::Error`, but
`Runtime::Error`, so this variant must exist
* env/backend: add `MANUAL_RESIZE` and `resize()`
* heed: respect `ReadersFull`, comment errors
* free: add `resize_memory_map()`
* env: add `Env::current_map_size`
* service: add `resize_map()`
* database: make `Env` itself cheaply clonable + threadsafe
`heed::Env` already uses `Arc` internally, but `sanakirja` does
not, so abstract this at the `Env` level instead of wrapping
`ConcreteEnv` in `Arc` ourselves.
* service: `Arc<ConcreteEnv>` -> `ConcreteEnv: Clone`
* env: add `SYNCS_PER_TX`, `path()`, `shutdown()`
* database: add `src/service/state.rs`
* service: add to `state.rs`, add `DatabaseState` to readers/writer
* add `parking_lot`
Okay, turns out we need to take locks in
`database/src/service/state.rs`...
`std`'s lock fairness policies are not well defined and
depend on the OS implementation, `parking_lot` on the other hand
has a fairness policy which is important when the writer needs
the lock but readers keep pouring in, essentially never letting
the writer do stuff.
* state: use `crossbeam::atomic::AtomicCell`
We have crossbeam as a dep anyway.
* heed: `heed::Env` -> `Arc<RwLock<heed::Env>>`
* service: add reader shutdown handle, use `Select` for msgs
* service: remove `state.rs`
We don't need this, we will represent shutdowns with channel
messages and `Select`, and mutual exclusion with a `RwLock`.
* service: fix misc reader/writer stuff
* database: add `config.rs`
* service: use `ReaderThreads` when spawning readers
* service: impl `shutdown()` for readers/writer
* service: return `DatabaseReaderReceivers` on shutdown via `JoinHandle`
Solves the issue of unfortunately timed `Request`s
that come in _right_ as we are shutting down.
If we (Cuprate) drop the database channels too early the requesting
thread will probably panic as they probably use `.unwrap()`,
never expecting a channel failure.
Returning this structure containing all the channels allows the
final shutdown code to carry these channels until the very end
of the program, at which point, all threads exit - no panics.
* remove `parking_lot`
Could be used as the database mutual exclusion lock.
Needs to be tested against `std`.
* config: add `path`
* env: `path()` -> `config()`, backend: impl `Drop`
* `Arc<ConcreteEnv>`, shutdown `service` on channel disconnect
* backend: add `Config` to `ConcreteEnv`
* service: use `std::thread::Builder` for readers/writer
* config: `PathBuf` -> `Cow<'static, Path>`
* misc docs, remove `RuntimeError::ShuttingDown`
* service: init & shutdown docs
* heed: impl `Env::resize_map()`
* heed: impl `Env::current_map_size()`
* lib.rs: add example crate usage test
* heed: `RwLock` comment
* helper: add `cuprate_database_dir()`
* config: use `cuprate_database_dir()`
* lib.rs: TODO example test
* database: add `page_size`
The database memory map size must be a multiple of
the OS page size. Why doesn't `heed` re-expose this?
It calls it when checking anyway...
https://docs.rs/heed/0.20.0-alpha.9/src/heed/env.rs.html#772
* free: impl `resize_memory_map()`
* free: docs
* env: add `disk_size_bytes()`
* config: impl `From<$num>` for `ReaderThreads`
* move `fs`-related constants to `cuprate_helper::fs`
* docs
* add `resize.rs`, `ResizeAlgorithm`
* env: use `ResizeAlgorithm` in `resize_map()`
* TODO: account for LMDB reader limit
* resize: docs, add `page_size()`, impl `fixed_bytes()`
* resize: impl `percent()`
* resize: docs
* env: take `ResizeAlgorithm` by value (it impls `Copy`)
* heed: TODO for `MDB_MAP_FULL` & `MDB_MAP_RESIZED`
* config: `From<Into<usize>>` for `ReaderThreads`
Co-authored-by: Boog900 <boog900@tutanota.com>
* env: move mutual exclusion doc to backend
* free: update invariant doc
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/service/mod.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* fix `[allow(unused_imports)] // docs`
* move DB filename from `helper/` -> `database/`
* config: use `DATABASE_FILENAME`
* config: add `db_file_path()`
* lib: add non-`service` usage invariant docs
* table: seal `Table` trait, impl for all `crate::tables`
* fix docs
* fix docs pt.2
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-02-25 19:46:36 +00:00
|
|
|
resize::ResizeAlgorithm,
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
table::Table,
|
2024-02-29 17:40:15 +00:00
|
|
|
transaction::{TxRo, TxRw},
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------- Env
|
|
|
|
/// Database environment abstraction.
|
|
|
|
///
|
database: Resizes, Shutdown, Flushing (#68)
* error: add `NeedsResize`
accidently removed, was `MapFull` before.
We need this because we as the writer thread must
react to this error in order to resize.
The writer thread doesn't have access to `heed::Error`, but
`Runtime::Error`, so this variant must exist
* env/backend: add `MANUAL_RESIZE` and `resize()`
* heed: respect `ReadersFull`, comment errors
* free: add `resize_memory_map()`
* env: add `Env::current_map_size`
* service: add `resize_map()`
* database: make `Env` itself cheaply clonable + threadsafe
`heed::Env` already uses `Arc` internally, but `sanakirja` does
not, so abstract this at the `Env` level instead of wrapping
`ConcreteEnv` in `Arc` ourselves.
* service: `Arc<ConcreteEnv>` -> `ConcreteEnv: Clone`
* env: add `SYNCS_PER_TX`, `path()`, `shutdown()`
* database: add `src/service/state.rs`
* service: add to `state.rs`, add `DatabaseState` to readers/writer
* add `parking_lot`
Okay, turns out we need to take locks in
`database/src/service/state.rs`...
`std`'s lock fairness policies are not well defined and
depend on the OS implementation, `parking_lot` on the other hand
has a fairness policy which is important when the writer needs
the lock but readers keep pouring in, essentially never letting
the writer do stuff.
* state: use `crossbeam::atomic::AtomicCell`
We have crossbeam as a dep anyway.
* heed: `heed::Env` -> `Arc<RwLock<heed::Env>>`
* service: add reader shutdown handle, use `Select` for msgs
* service: remove `state.rs`
We don't need this, we will represent shutdowns with channel
messages and `Select`, and mutual exclusion with a `RwLock`.
* service: fix misc reader/writer stuff
* database: add `config.rs`
* service: use `ReaderThreads` when spawning readers
* service: impl `shutdown()` for readers/writer
* service: return `DatabaseReaderReceivers` on shutdown via `JoinHandle`
Solves the issue of unfortunately timed `Request`s
that come in _right_ as we are shutting down.
If we (Cuprate) drop the database channels too early the requesting
thread will probably panic as they probably use `.unwrap()`,
never expecting a channel failure.
Returning this structure containing all the channels allows the
final shutdown code to carry these channels until the very end
of the program, at which point, all threads exit - no panics.
* remove `parking_lot`
Could be used as the database mutual exclusion lock.
Needs to be tested against `std`.
* config: add `path`
* env: `path()` -> `config()`, backend: impl `Drop`
* `Arc<ConcreteEnv>`, shutdown `service` on channel disconnect
* backend: add `Config` to `ConcreteEnv`
* service: use `std::thread::Builder` for readers/writer
* config: `PathBuf` -> `Cow<'static, Path>`
* misc docs, remove `RuntimeError::ShuttingDown`
* service: init & shutdown docs
* heed: impl `Env::resize_map()`
* heed: impl `Env::current_map_size()`
* lib.rs: add example crate usage test
* heed: `RwLock` comment
* helper: add `cuprate_database_dir()`
* config: use `cuprate_database_dir()`
* lib.rs: TODO example test
* database: add `page_size`
The database memory map size must be a multiple of
the OS page size. Why doesn't `heed` re-expose this?
It calls it when checking anyway...
https://docs.rs/heed/0.20.0-alpha.9/src/heed/env.rs.html#772
* free: impl `resize_memory_map()`
* free: docs
* env: add `disk_size_bytes()`
* config: impl `From<$num>` for `ReaderThreads`
* move `fs`-related constants to `cuprate_helper::fs`
* docs
* add `resize.rs`, `ResizeAlgorithm`
* env: use `ResizeAlgorithm` in `resize_map()`
* TODO: account for LMDB reader limit
* resize: docs, add `page_size()`, impl `fixed_bytes()`
* resize: impl `percent()`
* resize: docs
* env: take `ResizeAlgorithm` by value (it impls `Copy`)
* heed: TODO for `MDB_MAP_FULL` & `MDB_MAP_RESIZED`
* config: `From<Into<usize>>` for `ReaderThreads`
Co-authored-by: Boog900 <boog900@tutanota.com>
* env: move mutual exclusion doc to backend
* free: update invariant doc
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/service/mod.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* fix `[allow(unused_imports)] // docs`
* move DB filename from `helper/` -> `database/`
* config: use `DATABASE_FILENAME`
* config: add `db_file_path()`
* lib: add non-`service` usage invariant docs
* table: seal `Table` trait, impl for all `crate::tables`
* fix docs
* fix docs pt.2
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-02-25 19:46:36 +00:00
|
|
|
/// Essentially, the functions that can be called on [`ConcreteEnv`](crate::ConcreteEnv).
|
|
|
|
///
|
|
|
|
/// # `Drop`
|
|
|
|
/// Objects that implement [`Env`] _should_ probably
|
|
|
|
/// [`Env::sync`] in their drop implementations,
|
|
|
|
/// although, no invariant relies on this (yet).
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
///
|
|
|
|
/// # Lifetimes
|
2024-05-05 14:21:28 +00:00
|
|
|
/// The lifetimes associated with `Env` have a sequential flow:
|
2024-07-12 21:15:02 +00:00
|
|
|
/// ```text
|
|
|
|
/// Env -> Tx -> Database
|
|
|
|
/// ```
|
2024-05-05 14:21:28 +00:00
|
|
|
///
|
|
|
|
/// As in:
|
|
|
|
/// - open database tables only live as long as...
|
|
|
|
/// - transactions which only live as long as the...
|
2024-07-12 21:15:02 +00:00
|
|
|
/// - database environment
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
pub trait Env: Sized {
|
database: Resizes, Shutdown, Flushing (#68)
* error: add `NeedsResize`
accidently removed, was `MapFull` before.
We need this because we as the writer thread must
react to this error in order to resize.
The writer thread doesn't have access to `heed::Error`, but
`Runtime::Error`, so this variant must exist
* env/backend: add `MANUAL_RESIZE` and `resize()`
* heed: respect `ReadersFull`, comment errors
* free: add `resize_memory_map()`
* env: add `Env::current_map_size`
* service: add `resize_map()`
* database: make `Env` itself cheaply clonable + threadsafe
`heed::Env` already uses `Arc` internally, but `sanakirja` does
not, so abstract this at the `Env` level instead of wrapping
`ConcreteEnv` in `Arc` ourselves.
* service: `Arc<ConcreteEnv>` -> `ConcreteEnv: Clone`
* env: add `SYNCS_PER_TX`, `path()`, `shutdown()`
* database: add `src/service/state.rs`
* service: add to `state.rs`, add `DatabaseState` to readers/writer
* add `parking_lot`
Okay, turns out we need to take locks in
`database/src/service/state.rs`...
`std`'s lock fairness policies are not well defined and
depend on the OS implementation, `parking_lot` on the other hand
has a fairness policy which is important when the writer needs
the lock but readers keep pouring in, essentially never letting
the writer do stuff.
* state: use `crossbeam::atomic::AtomicCell`
We have crossbeam as a dep anyway.
* heed: `heed::Env` -> `Arc<RwLock<heed::Env>>`
* service: add reader shutdown handle, use `Select` for msgs
* service: remove `state.rs`
We don't need this, we will represent shutdowns with channel
messages and `Select`, and mutual exclusion with a `RwLock`.
* service: fix misc reader/writer stuff
* database: add `config.rs`
* service: use `ReaderThreads` when spawning readers
* service: impl `shutdown()` for readers/writer
* service: return `DatabaseReaderReceivers` on shutdown via `JoinHandle`
Solves the issue of unfortunately timed `Request`s
that come in _right_ as we are shutting down.
If we (Cuprate) drop the database channels too early the requesting
thread will probably panic as they probably use `.unwrap()`,
never expecting a channel failure.
Returning this structure containing all the channels allows the
final shutdown code to carry these channels until the very end
of the program, at which point, all threads exit - no panics.
* remove `parking_lot`
Could be used as the database mutual exclusion lock.
Needs to be tested against `std`.
* config: add `path`
* env: `path()` -> `config()`, backend: impl `Drop`
* `Arc<ConcreteEnv>`, shutdown `service` on channel disconnect
* backend: add `Config` to `ConcreteEnv`
* service: use `std::thread::Builder` for readers/writer
* config: `PathBuf` -> `Cow<'static, Path>`
* misc docs, remove `RuntimeError::ShuttingDown`
* service: init & shutdown docs
* heed: impl `Env::resize_map()`
* heed: impl `Env::current_map_size()`
* lib.rs: add example crate usage test
* heed: `RwLock` comment
* helper: add `cuprate_database_dir()`
* config: use `cuprate_database_dir()`
* lib.rs: TODO example test
* database: add `page_size`
The database memory map size must be a multiple of
the OS page size. Why doesn't `heed` re-expose this?
It calls it when checking anyway...
https://docs.rs/heed/0.20.0-alpha.9/src/heed/env.rs.html#772
* free: impl `resize_memory_map()`
* free: docs
* env: add `disk_size_bytes()`
* config: impl `From<$num>` for `ReaderThreads`
* move `fs`-related constants to `cuprate_helper::fs`
* docs
* add `resize.rs`, `ResizeAlgorithm`
* env: use `ResizeAlgorithm` in `resize_map()`
* TODO: account for LMDB reader limit
* resize: docs, add `page_size()`, impl `fixed_bytes()`
* resize: impl `percent()`
* resize: docs
* env: take `ResizeAlgorithm` by value (it impls `Copy`)
* heed: TODO for `MDB_MAP_FULL` & `MDB_MAP_RESIZED`
* config: `From<Into<usize>>` for `ReaderThreads`
Co-authored-by: Boog900 <boog900@tutanota.com>
* env: move mutual exclusion doc to backend
* free: update invariant doc
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/service/mod.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* fix `[allow(unused_imports)] // docs`
* move DB filename from `helper/` -> `database/`
* config: use `DATABASE_FILENAME`
* config: add `db_file_path()`
* lib: add non-`service` usage invariant docs
* table: seal `Table` trait, impl for all `crate::tables`
* fix docs
* fix docs pt.2
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-02-25 19:46:36 +00:00
|
|
|
//------------------------------------------------ Constants
|
|
|
|
/// Does the database backend need to be manually
|
|
|
|
/// resized when the memory-map is full?
|
|
|
|
///
|
|
|
|
/// # Invariant
|
|
|
|
/// If this is `false`, that means this [`Env`]
|
2024-05-05 14:21:28 +00:00
|
|
|
/// must _never_ return a [`RuntimeError::ResizeNeeded`].
|
database: Resizes, Shutdown, Flushing (#68)
* error: add `NeedsResize`
accidently removed, was `MapFull` before.
We need this because we as the writer thread must
react to this error in order to resize.
The writer thread doesn't have access to `heed::Error`, but
`Runtime::Error`, so this variant must exist
* env/backend: add `MANUAL_RESIZE` and `resize()`
* heed: respect `ReadersFull`, comment errors
* free: add `resize_memory_map()`
* env: add `Env::current_map_size`
* service: add `resize_map()`
* database: make `Env` itself cheaply clonable + threadsafe
`heed::Env` already uses `Arc` internally, but `sanakirja` does
not, so abstract this at the `Env` level instead of wrapping
`ConcreteEnv` in `Arc` ourselves.
* service: `Arc<ConcreteEnv>` -> `ConcreteEnv: Clone`
* env: add `SYNCS_PER_TX`, `path()`, `shutdown()`
* database: add `src/service/state.rs`
* service: add to `state.rs`, add `DatabaseState` to readers/writer
* add `parking_lot`
Okay, turns out we need to take locks in
`database/src/service/state.rs`...
`std`'s lock fairness policies are not well defined and
depend on the OS implementation, `parking_lot` on the other hand
has a fairness policy which is important when the writer needs
the lock but readers keep pouring in, essentially never letting
the writer do stuff.
* state: use `crossbeam::atomic::AtomicCell`
We have crossbeam as a dep anyway.
* heed: `heed::Env` -> `Arc<RwLock<heed::Env>>`
* service: add reader shutdown handle, use `Select` for msgs
* service: remove `state.rs`
We don't need this, we will represent shutdowns with channel
messages and `Select`, and mutual exclusion with a `RwLock`.
* service: fix misc reader/writer stuff
* database: add `config.rs`
* service: use `ReaderThreads` when spawning readers
* service: impl `shutdown()` for readers/writer
* service: return `DatabaseReaderReceivers` on shutdown via `JoinHandle`
Solves the issue of unfortunately timed `Request`s
that come in _right_ as we are shutting down.
If we (Cuprate) drop the database channels too early the requesting
thread will probably panic as they probably use `.unwrap()`,
never expecting a channel failure.
Returning this structure containing all the channels allows the
final shutdown code to carry these channels until the very end
of the program, at which point, all threads exit - no panics.
* remove `parking_lot`
Could be used as the database mutual exclusion lock.
Needs to be tested against `std`.
* config: add `path`
* env: `path()` -> `config()`, backend: impl `Drop`
* `Arc<ConcreteEnv>`, shutdown `service` on channel disconnect
* backend: add `Config` to `ConcreteEnv`
* service: use `std::thread::Builder` for readers/writer
* config: `PathBuf` -> `Cow<'static, Path>`
* misc docs, remove `RuntimeError::ShuttingDown`
* service: init & shutdown docs
* heed: impl `Env::resize_map()`
* heed: impl `Env::current_map_size()`
* lib.rs: add example crate usage test
* heed: `RwLock` comment
* helper: add `cuprate_database_dir()`
* config: use `cuprate_database_dir()`
* lib.rs: TODO example test
* database: add `page_size`
The database memory map size must be a multiple of
the OS page size. Why doesn't `heed` re-expose this?
It calls it when checking anyway...
https://docs.rs/heed/0.20.0-alpha.9/src/heed/env.rs.html#772
* free: impl `resize_memory_map()`
* free: docs
* env: add `disk_size_bytes()`
* config: impl `From<$num>` for `ReaderThreads`
* move `fs`-related constants to `cuprate_helper::fs`
* docs
* add `resize.rs`, `ResizeAlgorithm`
* env: use `ResizeAlgorithm` in `resize_map()`
* TODO: account for LMDB reader limit
* resize: docs, add `page_size()`, impl `fixed_bytes()`
* resize: impl `percent()`
* resize: docs
* env: take `ResizeAlgorithm` by value (it impls `Copy`)
* heed: TODO for `MDB_MAP_FULL` & `MDB_MAP_RESIZED`
* config: `From<Into<usize>>` for `ReaderThreads`
Co-authored-by: Boog900 <boog900@tutanota.com>
* env: move mutual exclusion doc to backend
* free: update invariant doc
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/service/mod.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* fix `[allow(unused_imports)] // docs`
* move DB filename from `helper/` -> `database/`
* config: use `DATABASE_FILENAME`
* config: add `db_file_path()`
* lib: add non-`service` usage invariant docs
* table: seal `Table` trait, impl for all `crate::tables`
* fix docs
* fix docs pt.2
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-02-25 19:46:36 +00:00
|
|
|
///
|
|
|
|
/// If this is `true`, [`Env::resize_map`] & [`Env::current_map_size`]
|
|
|
|
/// _must_ be re-implemented, as it just panics by default.
|
|
|
|
const MANUAL_RESIZE: bool;
|
|
|
|
|
|
|
|
/// Does the database backend forcefully sync/flush
|
|
|
|
/// to disk on every transaction commit?
|
|
|
|
///
|
|
|
|
/// This is used as an optimization.
|
|
|
|
const SYNCS_PER_TX: bool;
|
|
|
|
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
//------------------------------------------------ Types
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// The struct representing the actual backend's database environment.
|
|
|
|
///
|
|
|
|
/// This is used as the `self` in [`EnvInner`] functions, so whatever
|
|
|
|
/// this type is, is what will be accessible from those functions.
|
|
|
|
///
|
2024-05-05 14:21:28 +00:00
|
|
|
// # HACK
|
|
|
|
// For `heed`, this is just `heed::Env`, for `redb` this is
|
|
|
|
// `(redb::Database, redb::Durability)` as each transaction
|
|
|
|
// needs the sync mode set during creation.
|
2024-07-06 12:21:46 +00:00
|
|
|
type EnvInner<'env>: EnvInner<'env>
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
where
|
|
|
|
Self: 'env;
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// The read-only transaction type of the backend.
|
2024-07-06 12:21:46 +00:00
|
|
|
type TxRo<'env>: TxRo<'env>
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
where
|
|
|
|
Self: 'env;
|
|
|
|
|
|
|
|
/// The read/write transaction type of the backend.
|
2024-07-06 12:21:46 +00:00
|
|
|
type TxRw<'env>: TxRw<'env>
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
where
|
|
|
|
Self: 'env;
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
|
|
|
|
//------------------------------------------------ Required
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// Open the database environment, using the passed [`Config`].
|
|
|
|
///
|
|
|
|
/// # Invariants
|
2024-06-26 21:51:06 +00:00
|
|
|
/// This function does not create any tables.
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
///
|
2024-06-26 21:51:06 +00:00
|
|
|
/// You must create all possible tables with [`EnvInner::create_db`]
|
|
|
|
/// before attempting to open any.
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
///
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
/// # Errors
|
2024-06-26 21:51:06 +00:00
|
|
|
/// This will error if the database file could not be opened.
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
///
|
|
|
|
/// This is the only [`Env`] function that will return
|
|
|
|
/// an [`InitError`] instead of a [`RuntimeError`].
|
database: Resizes, Shutdown, Flushing (#68)
* error: add `NeedsResize`
accidently removed, was `MapFull` before.
We need this because we as the writer thread must
react to this error in order to resize.
The writer thread doesn't have access to `heed::Error`, but
`Runtime::Error`, so this variant must exist
* env/backend: add `MANUAL_RESIZE` and `resize()`
* heed: respect `ReadersFull`, comment errors
* free: add `resize_memory_map()`
* env: add `Env::current_map_size`
* service: add `resize_map()`
* database: make `Env` itself cheaply clonable + threadsafe
`heed::Env` already uses `Arc` internally, but `sanakirja` does
not, so abstract this at the `Env` level instead of wrapping
`ConcreteEnv` in `Arc` ourselves.
* service: `Arc<ConcreteEnv>` -> `ConcreteEnv: Clone`
* env: add `SYNCS_PER_TX`, `path()`, `shutdown()`
* database: add `src/service/state.rs`
* service: add to `state.rs`, add `DatabaseState` to readers/writer
* add `parking_lot`
Okay, turns out we need to take locks in
`database/src/service/state.rs`...
`std`'s lock fairness policies are not well defined and
depend on the OS implementation, `parking_lot` on the other hand
has a fairness policy which is important when the writer needs
the lock but readers keep pouring in, essentially never letting
the writer do stuff.
* state: use `crossbeam::atomic::AtomicCell`
We have crossbeam as a dep anyway.
* heed: `heed::Env` -> `Arc<RwLock<heed::Env>>`
* service: add reader shutdown handle, use `Select` for msgs
* service: remove `state.rs`
We don't need this, we will represent shutdowns with channel
messages and `Select`, and mutual exclusion with a `RwLock`.
* service: fix misc reader/writer stuff
* database: add `config.rs`
* service: use `ReaderThreads` when spawning readers
* service: impl `shutdown()` for readers/writer
* service: return `DatabaseReaderReceivers` on shutdown via `JoinHandle`
Solves the issue of unfortunately timed `Request`s
that come in _right_ as we are shutting down.
If we (Cuprate) drop the database channels too early the requesting
thread will probably panic as they probably use `.unwrap()`,
never expecting a channel failure.
Returning this structure containing all the channels allows the
final shutdown code to carry these channels until the very end
of the program, at which point, all threads exit - no panics.
* remove `parking_lot`
Could be used as the database mutual exclusion lock.
Needs to be tested against `std`.
* config: add `path`
* env: `path()` -> `config()`, backend: impl `Drop`
* `Arc<ConcreteEnv>`, shutdown `service` on channel disconnect
* backend: add `Config` to `ConcreteEnv`
* service: use `std::thread::Builder` for readers/writer
* config: `PathBuf` -> `Cow<'static, Path>`
* misc docs, remove `RuntimeError::ShuttingDown`
* service: init & shutdown docs
* heed: impl `Env::resize_map()`
* heed: impl `Env::current_map_size()`
* lib.rs: add example crate usage test
* heed: `RwLock` comment
* helper: add `cuprate_database_dir()`
* config: use `cuprate_database_dir()`
* lib.rs: TODO example test
* database: add `page_size`
The database memory map size must be a multiple of
the OS page size. Why doesn't `heed` re-expose this?
It calls it when checking anyway...
https://docs.rs/heed/0.20.0-alpha.9/src/heed/env.rs.html#772
* free: impl `resize_memory_map()`
* free: docs
* env: add `disk_size_bytes()`
* config: impl `From<$num>` for `ReaderThreads`
* move `fs`-related constants to `cuprate_helper::fs`
* docs
* add `resize.rs`, `ResizeAlgorithm`
* env: use `ResizeAlgorithm` in `resize_map()`
* TODO: account for LMDB reader limit
* resize: docs, add `page_size()`, impl `fixed_bytes()`
* resize: impl `percent()`
* resize: docs
* env: take `ResizeAlgorithm` by value (it impls `Copy`)
* heed: TODO for `MDB_MAP_FULL` & `MDB_MAP_RESIZED`
* config: `From<Into<usize>>` for `ReaderThreads`
Co-authored-by: Boog900 <boog900@tutanota.com>
* env: move mutual exclusion doc to backend
* free: update invariant doc
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/service/mod.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* fix `[allow(unused_imports)] // docs`
* move DB filename from `helper/` -> `database/`
* config: use `DATABASE_FILENAME`
* config: add `db_file_path()`
* lib: add non-`service` usage invariant docs
* table: seal `Table` trait, impl for all `crate::tables`
* fix docs
* fix docs pt.2
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-02-25 19:46:36 +00:00
|
|
|
fn open(config: Config) -> Result<Self, InitError>;
|
|
|
|
|
|
|
|
/// Return the [`Config`] that this database was [`Env::open`]ed with.
|
|
|
|
fn config(&self) -> &Config;
|
|
|
|
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// Fully sync the database caches to disk.
|
2024-02-29 17:40:15 +00:00
|
|
|
///
|
|
|
|
/// # Invariant
|
|
|
|
/// This must **fully** and **synchronously** flush the database data to disk.
|
|
|
|
///
|
|
|
|
/// I.e., after this function returns, there must be no doubts
|
|
|
|
/// that the data isn't synced yet, it _must_ be synced.
|
|
|
|
///
|
2024-05-05 14:21:28 +00:00
|
|
|
// FIXME: either this invariant or `sync()` itself will most
|
|
|
|
// likely be removed/changed after `SyncMode` is finalized.
|
2024-02-29 17:40:15 +00:00
|
|
|
///
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
/// # Errors
|
2024-05-05 14:21:28 +00:00
|
|
|
/// If there is a synchronization error, this should return an error.
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
fn sync(&self) -> Result<(), RuntimeError>;
|
|
|
|
|
database: Resizes, Shutdown, Flushing (#68)
* error: add `NeedsResize`
accidently removed, was `MapFull` before.
We need this because we as the writer thread must
react to this error in order to resize.
The writer thread doesn't have access to `heed::Error`, but
`Runtime::Error`, so this variant must exist
* env/backend: add `MANUAL_RESIZE` and `resize()`
* heed: respect `ReadersFull`, comment errors
* free: add `resize_memory_map()`
* env: add `Env::current_map_size`
* service: add `resize_map()`
* database: make `Env` itself cheaply clonable + threadsafe
`heed::Env` already uses `Arc` internally, but `sanakirja` does
not, so abstract this at the `Env` level instead of wrapping
`ConcreteEnv` in `Arc` ourselves.
* service: `Arc<ConcreteEnv>` -> `ConcreteEnv: Clone`
* env: add `SYNCS_PER_TX`, `path()`, `shutdown()`
* database: add `src/service/state.rs`
* service: add to `state.rs`, add `DatabaseState` to readers/writer
* add `parking_lot`
Okay, turns out we need to take locks in
`database/src/service/state.rs`...
`std`'s lock fairness policies are not well defined and
depend on the OS implementation, `parking_lot` on the other hand
has a fairness policy which is important when the writer needs
the lock but readers keep pouring in, essentially never letting
the writer do stuff.
* state: use `crossbeam::atomic::AtomicCell`
We have crossbeam as a dep anyway.
* heed: `heed::Env` -> `Arc<RwLock<heed::Env>>`
* service: add reader shutdown handle, use `Select` for msgs
* service: remove `state.rs`
We don't need this, we will represent shutdowns with channel
messages and `Select`, and mutual exclusion with a `RwLock`.
* service: fix misc reader/writer stuff
* database: add `config.rs`
* service: use `ReaderThreads` when spawning readers
* service: impl `shutdown()` for readers/writer
* service: return `DatabaseReaderReceivers` on shutdown via `JoinHandle`
Solves the issue of unfortunately timed `Request`s
that come in _right_ as we are shutting down.
If we (Cuprate) drop the database channels too early the requesting
thread will probably panic as they probably use `.unwrap()`,
never expecting a channel failure.
Returning this structure containing all the channels allows the
final shutdown code to carry these channels until the very end
of the program, at which point, all threads exit - no panics.
* remove `parking_lot`
Could be used as the database mutual exclusion lock.
Needs to be tested against `std`.
* config: add `path`
* env: `path()` -> `config()`, backend: impl `Drop`
* `Arc<ConcreteEnv>`, shutdown `service` on channel disconnect
* backend: add `Config` to `ConcreteEnv`
* service: use `std::thread::Builder` for readers/writer
* config: `PathBuf` -> `Cow<'static, Path>`
* misc docs, remove `RuntimeError::ShuttingDown`
* service: init & shutdown docs
* heed: impl `Env::resize_map()`
* heed: impl `Env::current_map_size()`
* lib.rs: add example crate usage test
* heed: `RwLock` comment
* helper: add `cuprate_database_dir()`
* config: use `cuprate_database_dir()`
* lib.rs: TODO example test
* database: add `page_size`
The database memory map size must be a multiple of
the OS page size. Why doesn't `heed` re-expose this?
It calls it when checking anyway...
https://docs.rs/heed/0.20.0-alpha.9/src/heed/env.rs.html#772
* free: impl `resize_memory_map()`
* free: docs
* env: add `disk_size_bytes()`
* config: impl `From<$num>` for `ReaderThreads`
* move `fs`-related constants to `cuprate_helper::fs`
* docs
* add `resize.rs`, `ResizeAlgorithm`
* env: use `ResizeAlgorithm` in `resize_map()`
* TODO: account for LMDB reader limit
* resize: docs, add `page_size()`, impl `fixed_bytes()`
* resize: impl `percent()`
* resize: docs
* env: take `ResizeAlgorithm` by value (it impls `Copy`)
* heed: TODO for `MDB_MAP_FULL` & `MDB_MAP_RESIZED`
* config: `From<Into<usize>>` for `ReaderThreads`
Co-authored-by: Boog900 <boog900@tutanota.com>
* env: move mutual exclusion doc to backend
* free: update invariant doc
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/service/mod.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* fix `[allow(unused_imports)] // docs`
* move DB filename from `helper/` -> `database/`
* config: use `DATABASE_FILENAME`
* config: add `db_file_path()`
* lib: add non-`service` usage invariant docs
* table: seal `Table` trait, impl for all `crate::tables`
* fix docs
* fix docs pt.2
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-02-25 19:46:36 +00:00
|
|
|
/// Resize the database's memory map to a
|
|
|
|
/// new (bigger) size using a [`ResizeAlgorithm`].
|
|
|
|
///
|
|
|
|
/// By default, this function will use the `ResizeAlgorithm` in [`Env::config`].
|
|
|
|
///
|
|
|
|
/// If `resize_algorithm` is `Some`, that will be used instead.
|
|
|
|
///
|
2024-04-16 22:05:38 +00:00
|
|
|
/// This function returns the _new_ memory map size in bytes.
|
|
|
|
///
|
database: Resizes, Shutdown, Flushing (#68)
* error: add `NeedsResize`
accidently removed, was `MapFull` before.
We need this because we as the writer thread must
react to this error in order to resize.
The writer thread doesn't have access to `heed::Error`, but
`Runtime::Error`, so this variant must exist
* env/backend: add `MANUAL_RESIZE` and `resize()`
* heed: respect `ReadersFull`, comment errors
* free: add `resize_memory_map()`
* env: add `Env::current_map_size`
* service: add `resize_map()`
* database: make `Env` itself cheaply clonable + threadsafe
`heed::Env` already uses `Arc` internally, but `sanakirja` does
not, so abstract this at the `Env` level instead of wrapping
`ConcreteEnv` in `Arc` ourselves.
* service: `Arc<ConcreteEnv>` -> `ConcreteEnv: Clone`
* env: add `SYNCS_PER_TX`, `path()`, `shutdown()`
* database: add `src/service/state.rs`
* service: add to `state.rs`, add `DatabaseState` to readers/writer
* add `parking_lot`
Okay, turns out we need to take locks in
`database/src/service/state.rs`...
`std`'s lock fairness policies are not well defined and
depend on the OS implementation, `parking_lot` on the other hand
has a fairness policy which is important when the writer needs
the lock but readers keep pouring in, essentially never letting
the writer do stuff.
* state: use `crossbeam::atomic::AtomicCell`
We have crossbeam as a dep anyway.
* heed: `heed::Env` -> `Arc<RwLock<heed::Env>>`
* service: add reader shutdown handle, use `Select` for msgs
* service: remove `state.rs`
We don't need this, we will represent shutdowns with channel
messages and `Select`, and mutual exclusion with a `RwLock`.
* service: fix misc reader/writer stuff
* database: add `config.rs`
* service: use `ReaderThreads` when spawning readers
* service: impl `shutdown()` for readers/writer
* service: return `DatabaseReaderReceivers` on shutdown via `JoinHandle`
Solves the issue of unfortunately timed `Request`s
that come in _right_ as we are shutting down.
If we (Cuprate) drop the database channels too early the requesting
thread will probably panic as they probably use `.unwrap()`,
never expecting a channel failure.
Returning this structure containing all the channels allows the
final shutdown code to carry these channels until the very end
of the program, at which point, all threads exit - no panics.
* remove `parking_lot`
Could be used as the database mutual exclusion lock.
Needs to be tested against `std`.
* config: add `path`
* env: `path()` -> `config()`, backend: impl `Drop`
* `Arc<ConcreteEnv>`, shutdown `service` on channel disconnect
* backend: add `Config` to `ConcreteEnv`
* service: use `std::thread::Builder` for readers/writer
* config: `PathBuf` -> `Cow<'static, Path>`
* misc docs, remove `RuntimeError::ShuttingDown`
* service: init & shutdown docs
* heed: impl `Env::resize_map()`
* heed: impl `Env::current_map_size()`
* lib.rs: add example crate usage test
* heed: `RwLock` comment
* helper: add `cuprate_database_dir()`
* config: use `cuprate_database_dir()`
* lib.rs: TODO example test
* database: add `page_size`
The database memory map size must be a multiple of
the OS page size. Why doesn't `heed` re-expose this?
It calls it when checking anyway...
https://docs.rs/heed/0.20.0-alpha.9/src/heed/env.rs.html#772
* free: impl `resize_memory_map()`
* free: docs
* env: add `disk_size_bytes()`
* config: impl `From<$num>` for `ReaderThreads`
* move `fs`-related constants to `cuprate_helper::fs`
* docs
* add `resize.rs`, `ResizeAlgorithm`
* env: use `ResizeAlgorithm` in `resize_map()`
* TODO: account for LMDB reader limit
* resize: docs, add `page_size()`, impl `fixed_bytes()`
* resize: impl `percent()`
* resize: docs
* env: take `ResizeAlgorithm` by value (it impls `Copy`)
* heed: TODO for `MDB_MAP_FULL` & `MDB_MAP_RESIZED`
* config: `From<Into<usize>>` for `ReaderThreads`
Co-authored-by: Boog900 <boog900@tutanota.com>
* env: move mutual exclusion doc to backend
* free: update invariant doc
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/service/mod.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* fix `[allow(unused_imports)] // docs`
* move DB filename from `helper/` -> `database/`
* config: use `DATABASE_FILENAME`
* config: add `db_file_path()`
* lib: add non-`service` usage invariant docs
* table: seal `Table` trait, impl for all `crate::tables`
* fix docs
* fix docs pt.2
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-02-25 19:46:36 +00:00
|
|
|
/// # Invariant
|
|
|
|
/// This function _must_ be re-implemented if [`Env::MANUAL_RESIZE`] is `true`.
|
|
|
|
///
|
|
|
|
/// Otherwise, this function will panic with `unreachable!()`.
|
2024-05-05 14:21:28 +00:00
|
|
|
#[allow(unused_variables)]
|
2024-04-16 22:05:38 +00:00
|
|
|
fn resize_map(&self, resize_algorithm: Option<ResizeAlgorithm>) -> NonZeroUsize {
|
database: Resizes, Shutdown, Flushing (#68)
* error: add `NeedsResize`
accidently removed, was `MapFull` before.
We need this because we as the writer thread must
react to this error in order to resize.
The writer thread doesn't have access to `heed::Error`, but
`Runtime::Error`, so this variant must exist
* env/backend: add `MANUAL_RESIZE` and `resize()`
* heed: respect `ReadersFull`, comment errors
* free: add `resize_memory_map()`
* env: add `Env::current_map_size`
* service: add `resize_map()`
* database: make `Env` itself cheaply clonable + threadsafe
`heed::Env` already uses `Arc` internally, but `sanakirja` does
not, so abstract this at the `Env` level instead of wrapping
`ConcreteEnv` in `Arc` ourselves.
* service: `Arc<ConcreteEnv>` -> `ConcreteEnv: Clone`
* env: add `SYNCS_PER_TX`, `path()`, `shutdown()`
* database: add `src/service/state.rs`
* service: add to `state.rs`, add `DatabaseState` to readers/writer
* add `parking_lot`
Okay, turns out we need to take locks in
`database/src/service/state.rs`...
`std`'s lock fairness policies are not well defined and
depend on the OS implementation, `parking_lot` on the other hand
has a fairness policy which is important when the writer needs
the lock but readers keep pouring in, essentially never letting
the writer do stuff.
* state: use `crossbeam::atomic::AtomicCell`
We have crossbeam as a dep anyway.
* heed: `heed::Env` -> `Arc<RwLock<heed::Env>>`
* service: add reader shutdown handle, use `Select` for msgs
* service: remove `state.rs`
We don't need this, we will represent shutdowns with channel
messages and `Select`, and mutual exclusion with a `RwLock`.
* service: fix misc reader/writer stuff
* database: add `config.rs`
* service: use `ReaderThreads` when spawning readers
* service: impl `shutdown()` for readers/writer
* service: return `DatabaseReaderReceivers` on shutdown via `JoinHandle`
Solves the issue of unfortunately timed `Request`s
that come in _right_ as we are shutting down.
If we (Cuprate) drop the database channels too early the requesting
thread will probably panic as they probably use `.unwrap()`,
never expecting a channel failure.
Returning this structure containing all the channels allows the
final shutdown code to carry these channels until the very end
of the program, at which point, all threads exit - no panics.
* remove `parking_lot`
Could be used as the database mutual exclusion lock.
Needs to be tested against `std`.
* config: add `path`
* env: `path()` -> `config()`, backend: impl `Drop`
* `Arc<ConcreteEnv>`, shutdown `service` on channel disconnect
* backend: add `Config` to `ConcreteEnv`
* service: use `std::thread::Builder` for readers/writer
* config: `PathBuf` -> `Cow<'static, Path>`
* misc docs, remove `RuntimeError::ShuttingDown`
* service: init & shutdown docs
* heed: impl `Env::resize_map()`
* heed: impl `Env::current_map_size()`
* lib.rs: add example crate usage test
* heed: `RwLock` comment
* helper: add `cuprate_database_dir()`
* config: use `cuprate_database_dir()`
* lib.rs: TODO example test
* database: add `page_size`
The database memory map size must be a multiple of
the OS page size. Why doesn't `heed` re-expose this?
It calls it when checking anyway...
https://docs.rs/heed/0.20.0-alpha.9/src/heed/env.rs.html#772
* free: impl `resize_memory_map()`
* free: docs
* env: add `disk_size_bytes()`
* config: impl `From<$num>` for `ReaderThreads`
* move `fs`-related constants to `cuprate_helper::fs`
* docs
* add `resize.rs`, `ResizeAlgorithm`
* env: use `ResizeAlgorithm` in `resize_map()`
* TODO: account for LMDB reader limit
* resize: docs, add `page_size()`, impl `fixed_bytes()`
* resize: impl `percent()`
* resize: docs
* env: take `ResizeAlgorithm` by value (it impls `Copy`)
* heed: TODO for `MDB_MAP_FULL` & `MDB_MAP_RESIZED`
* config: `From<Into<usize>>` for `ReaderThreads`
Co-authored-by: Boog900 <boog900@tutanota.com>
* env: move mutual exclusion doc to backend
* free: update invariant doc
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/service/mod.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* fix `[allow(unused_imports)] // docs`
* move DB filename from `helper/` -> `database/`
* config: use `DATABASE_FILENAME`
* config: add `db_file_path()`
* lib: add non-`service` usage invariant docs
* table: seal `Table` trait, impl for all `crate::tables`
* fix docs
* fix docs pt.2
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-02-25 19:46:36 +00:00
|
|
|
unreachable!()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// What is the _current_ size of the database's memory map in bytes?
|
|
|
|
///
|
|
|
|
/// # Invariant
|
|
|
|
/// 1. This function _must_ be re-implemented if [`Env::MANUAL_RESIZE`] is `true`.
|
|
|
|
/// 2. This function must be accurate, as [`Env::resize_map()`] may depend on it.
|
|
|
|
fn current_map_size(&self) -> usize {
|
|
|
|
unreachable!()
|
|
|
|
}
|
|
|
|
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// Return the [`Env::EnvInner`].
|
|
|
|
///
|
|
|
|
/// # Locking behavior
|
|
|
|
/// When using the `heed` backend, [`Env::EnvInner`] is a
|
|
|
|
/// `RwLockReadGuard`, i.e., calling this function takes a
|
|
|
|
/// read lock on the `heed::Env`.
|
|
|
|
///
|
|
|
|
/// Be aware of this, as other functions (currently only
|
|
|
|
/// [`Env::resize_map`]) will take a _write_ lock.
|
|
|
|
fn env_inner(&self) -> Self::EnvInner<'_>;
|
|
|
|
|
|
|
|
//------------------------------------------------ Provided
|
|
|
|
/// Return the amount of actual of bytes the database is taking up on disk.
|
|
|
|
///
|
|
|
|
/// This is the current _disk_ value in bytes, not the memory map.
|
|
|
|
///
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
/// # Errors
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// This will error if either:
|
|
|
|
///
|
|
|
|
/// - [`std::fs::File::open`]
|
|
|
|
/// - [`std::fs::File::metadata`]
|
|
|
|
///
|
|
|
|
/// failed on the database file on disk.
|
|
|
|
fn disk_size_bytes(&self) -> std::io::Result<u64> {
|
|
|
|
// We have the direct PATH to the file,
|
|
|
|
// no need to use backend-specific functions.
|
|
|
|
//
|
|
|
|
// SAFETY: as we are only accessing the metadata of
|
|
|
|
// the file and not reading the bytes, it should be
|
|
|
|
// fine even with a memory mapped file being actively
|
|
|
|
// written to.
|
|
|
|
Ok(std::fs::File::open(&self.config().db_file)?
|
|
|
|
.metadata()?
|
|
|
|
.len())
|
|
|
|
}
|
|
|
|
}
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
//---------------------------------------------------------------------------------------------------- DatabaseRo
|
2024-07-01 19:24:48 +00:00
|
|
|
/// Document the INVARIANT that the `heed` backend
|
|
|
|
/// must use [`EnvInner::create_db`] when initially
|
|
|
|
/// opening/creating tables.
|
|
|
|
macro_rules! doc_heed_create_db_invariant {
|
2024-05-05 14:21:28 +00:00
|
|
|
() => {
|
2024-07-01 19:24:48 +00:00
|
|
|
r#"The first time you open/create tables, you _must_ use [`EnvInner::create_db`]
|
|
|
|
to set the proper flags / [`Key`](crate::Key) comparison for the `heed` backend.
|
2024-05-05 14:21:28 +00:00
|
|
|
|
2024-07-01 19:24:48 +00:00
|
|
|
Subsequent table opens will follow the flags/ordering, but only if
|
|
|
|
[`EnvInner::create_db`] was the _first_ function to open/create it."#
|
2024-05-05 14:21:28 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/// The inner [`Env`] type.
|
|
|
|
///
|
|
|
|
/// This type is created with [`Env::env_inner`] and represents
|
|
|
|
/// the type able to generate transactions and open tables.
|
|
|
|
///
|
|
|
|
/// # Locking behavior
|
|
|
|
/// As noted in `Env::env_inner`, this is a `RwLockReadGuard`
|
|
|
|
/// when using the `heed` backend, be aware of this and do
|
|
|
|
/// not hold onto an `EnvInner` for a long time.
|
2024-06-26 21:51:06 +00:00
|
|
|
///
|
|
|
|
/// # Tables
|
|
|
|
/// Note that when opening tables with [`EnvInner::open_db_ro`],
|
|
|
|
/// they must be created first or else it will return error.
|
|
|
|
///
|
2024-07-01 19:24:48 +00:00
|
|
|
/// See [`EnvInner::create_db`] for creating tables.
|
|
|
|
///
|
|
|
|
/// # Invariant
|
|
|
|
#[doc = doc_heed_create_db_invariant!()]
|
2024-07-06 12:21:46 +00:00
|
|
|
pub trait EnvInner<'env> {
|
|
|
|
/// The read-only transaction type of the backend.
|
2024-07-12 21:15:02 +00:00
|
|
|
///
|
|
|
|
/// `'tx` is the lifetime of the transaction itself.
|
|
|
|
type Ro<'tx>: TxRo<'tx>;
|
2024-07-06 12:21:46 +00:00
|
|
|
/// The read-write transaction type of the backend.
|
2024-07-12 21:15:02 +00:00
|
|
|
///
|
|
|
|
/// `'tx` is the lifetime of the transaction itself.
|
|
|
|
type Rw<'tx>: TxRw<'tx>;
|
2024-07-06 12:21:46 +00:00
|
|
|
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// Create a read-only transaction.
|
|
|
|
///
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
/// # Errors
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// This will only return [`RuntimeError::Io`] if it errors.
|
2024-07-06 12:21:46 +00:00
|
|
|
fn tx_ro(&self) -> Result<Self::Ro<'_>, RuntimeError>;
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// Create a read/write transaction.
|
|
|
|
///
|
|
|
|
/// # Errors
|
|
|
|
/// This will only return [`RuntimeError::Io`] if it errors.
|
2024-07-06 12:21:46 +00:00
|
|
|
fn tx_rw(&self) -> Result<Self::Rw<'_>, RuntimeError>;
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
|
|
|
|
/// Open a database in read-only mode.
|
2024-02-29 17:40:15 +00:00
|
|
|
///
|
2024-05-05 14:21:28 +00:00
|
|
|
/// The returned value can have [`DatabaseRo`]
|
|
|
|
/// & [`DatabaseIter`] functions called on it.
|
|
|
|
///
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// This will open the database [`Table`]
|
|
|
|
/// passed as a generic to this function.
|
2024-02-29 17:40:15 +00:00
|
|
|
///
|
2024-07-12 21:15:02 +00:00
|
|
|
/// ```rust
|
|
|
|
/// # use cuprate_database::{
|
|
|
|
/// # ConcreteEnv,
|
|
|
|
/// # config::ConfigBuilder,
|
|
|
|
/// # Env, EnvInner,
|
|
|
|
/// # DatabaseRo, DatabaseRw, TxRo, TxRw,
|
|
|
|
/// # };
|
|
|
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
/// # let tmp_dir = tempfile::tempdir()?;
|
|
|
|
/// # let db_dir = tmp_dir.path().to_owned();
|
|
|
|
/// # let config = ConfigBuilder::new(db_dir.into()).build();
|
|
|
|
/// # let env = ConcreteEnv::open(config)?;
|
|
|
|
/// #
|
|
|
|
/// # struct Table;
|
|
|
|
/// # impl cuprate_database::Table for Table {
|
|
|
|
/// # const NAME: &'static str = "table";
|
|
|
|
/// # type Key = u8;
|
|
|
|
/// # type Value = u64;
|
|
|
|
/// # }
|
|
|
|
/// #
|
|
|
|
/// # let env_inner = env.env_inner();
|
|
|
|
/// # let tx_rw = env_inner.tx_rw()?;
|
|
|
|
/// # env_inner.create_db::<Table>(&tx_rw)?;
|
|
|
|
/// # TxRw::commit(tx_rw);
|
|
|
|
/// #
|
|
|
|
/// # let tx_ro = env_inner.tx_ro()?;
|
|
|
|
/// let db = env_inner.open_db_ro::<Table>(&tx_ro);
|
|
|
|
/// // ^ ^
|
|
|
|
/// // database table table metadata
|
|
|
|
/// // (name, key/value type)
|
|
|
|
/// # Ok(()) }
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// ```
|
2024-02-29 17:40:15 +00:00
|
|
|
///
|
2024-06-26 21:51:06 +00:00
|
|
|
/// # Errors
|
|
|
|
/// This will only return [`RuntimeError::Io`] on normal errors.
|
|
|
|
///
|
|
|
|
/// If the specified table is not created upon before this function is called,
|
|
|
|
/// this will return [`RuntimeError::TableNotFound`].
|
2024-07-01 19:24:48 +00:00
|
|
|
///
|
|
|
|
/// # Invariant
|
|
|
|
#[doc = doc_heed_create_db_invariant!()]
|
2024-04-03 21:44:25 +00:00
|
|
|
fn open_db_ro<T: Table>(
|
|
|
|
&self,
|
2024-07-06 12:21:46 +00:00
|
|
|
tx_ro: &Self::Ro<'_>,
|
2024-04-03 21:44:25 +00:00
|
|
|
) -> Result<impl DatabaseRo<T> + DatabaseIter<T>, RuntimeError>;
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// Open a database in read/write mode.
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
///
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// All [`DatabaseRo`] functions are also callable
|
|
|
|
/// with the returned [`DatabaseRw`] structure.
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
///
|
2024-05-05 14:21:28 +00:00
|
|
|
/// Note that [`DatabaseIter`] functions are _not_
|
|
|
|
/// available to [`DatabaseRw`] structures.
|
|
|
|
///
|
database: impl trait function bodies for `heed` & `redb` (#85)
* env: remove `T: Table` for `Env::create_tables()`
It creates _all_ tables, not a specific `T: Table`
* heed: half impl `Env::open()`, some TODOs
* heed: add `HeedTxR{o,w}<'env>`
* workspace/cargo: add `parking_lot`
* remove `parking_lot`
`MappedRwLockGuard` doesn't solve the `returning reference to
object owned by function` error when returning heed's lock guard
+ the tx so we'll be going with `std`
* env: add `{EnvInner,TxRoInput,TxRwInput}` and getter `fn()`s
* env: fix tx <-> table lifetimes, fix `Env::create_tables()`
* heed: impl `DatabaseRo`
* heed: impl `DatabaseRw`
* database: add `src/backend/${BACKEND}/tests.rs`
* heed: impl more of `Env::open()`
* redb: fix trait signatures, add `trait ValueGuard`
* accommodate `DatabaseRo` bounds for both `{heed,redb}`
* fold `get_range()` generic + bounds
* add `TxCreator`, add `heed` tests
* env: `TxCreator` -> `EnvInner` which doubles as DB/Table opener
* database: `DatabaseRw<'tx>` -> `DatabaseRw<'db, 'tx>`
* heed: `db_read_write()` test
* database: fix `get()` lifetimes, heed: add `db_read_write()` test
* database: remove `'env` lifetime from `DatabaseRo<'env, 'tx>`
not needed for immutable references
* redb: fix new `{Env, EnvInner, DatabaseR{o,w}}` bounds
* redb: impl `Database` traits
* redb: impl `TxR{o,w}` traits
* redb: impl `Env`
* redb: open/create tables in `Env::open`
* redb: enable tests, add tmp `Storable` printlns
* redb: fix alignment issue with `Cow` and `from_bytes_unaligned()`
* redb: only allocate bytes when alignment != 1
* heed: remove custom iterator from `range()`
* storable: conditionally allocat on misaligned bytes in `from_bytes`
* add database guard
* database: AccessGuard -> ValueGuard
* storable: add `ALIGN` and `from_bytes_unaligned()`
* redb: 1 serde type `StorableRedb`, fix impl
* cow serde, trait bounds, fix backend's where bounds
- Uses Cow for `redb`'s deserialization
- Conforms `heed` to use Cow (but not as the actual key/value)
- Conforms the `cuprate_database` trait API to use Cow
- Adds `ToOwned + Debug` (and permutation) trait bounds
- Solves 23098573148968945687345349657398 compiler errors due
to aforementioned trait bounds, causing `where` to be everywhere
* fix docs, use fully qualified Tx functions for tests
* backend: check value guard contains value in test
* add `Storable::ALIGN` tests, doc TODOs
* add `trait ToOwnedDebug`
* traits: `ToOwned + Debug` -> `ToOwnedDebug`
* heed: remove `ToOwned` + `Debug` bounds
* redb: remove `ToOwned` + `Debug` bounds
* add `ValueGuard`, replace signatures, fix `redb`
* heed: fix for `ValueGuard`
* docs, tests
* redb: add `CowRange` for `T::Key` -> `Cow<'_, T::Key>` conversion
* separate `config.rs` -> `config/`
* ci: combine tests, run both `heed` and `redb` tests
* ci: fix workflow
* backend: add `resize()` test
* ci: remove windows-specific update
* ci: remove update + windows default set
* backend: add `unreachable` tests, fix docs
* trait docs
* ci: fix
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/env.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/transaction.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/redb/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* Update database/src/backend/heed/database.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* readme: fix `value_guard.rs`
* heed: remove unneeded clippy + fix formatting
* heed: create and use `create_table()` in `Env::open()`
* redb: create and use `create_table()` in `Env::open()`
* redb: remove unneeded clippy
* fix clippy, remove `<[u8], [u8]>` docs
---------
Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-03-13 22:05:24 +00:00
|
|
|
/// This will open the database [`Table`]
|
|
|
|
/// passed as a generic to this function.
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
///
|
2024-06-26 21:51:06 +00:00
|
|
|
/// # Errors
|
|
|
|
/// This will only return [`RuntimeError::Io`] on errors.
|
2024-05-05 14:21:28 +00:00
|
|
|
///
|
2024-07-01 19:24:48 +00:00
|
|
|
/// # Invariant
|
|
|
|
#[doc = doc_heed_create_db_invariant!()]
|
2024-07-06 12:21:46 +00:00
|
|
|
fn open_db_rw<T: Table>(
|
|
|
|
&self,
|
|
|
|
tx_rw: &Self::Rw<'_>,
|
|
|
|
) -> Result<impl DatabaseRw<T>, RuntimeError>;
|
database: implement `ops/` (#102)
* ops: add `trait MoneroR{o,w}`
* update `trait MoneroR{o,w}` bounds
* types: add `BlockInfoLatest` type alias
* block: impl most core functions
* types: fix https://github.com/Cuprate/cuprate/pull/91#discussion_r1527668916
* fix table type test
* cargo.toml: add `{cuprate-types, monero-serai}`
* add_block: add all other block data
* ops: remove unneeded `block` functions
* env: add `EnvInner::open_db_rw_all()`
* types: fix test
* block: `&mut TxRw` -> `&TxRw`, use `open_db_rw_all()`
* add `trait Tables[Mut]` and use it in `EnvInner`
* block: use `TablesMut`
* tables: replace manual impl with `define_trait_tables!()`
* tables: docs for `trait Tables[Mut]`
* tables: doc functions
* create `call_fn_on_all_tables_or_early_return!()` macro
* block: cleanup signatures + bodies
* block: more fn's, docs
* block: add `doc_{error,single,bulk}!()`
* remove `ops/monero.rs`
* move `height()` to `ops/blockchain.rs`
* add `ops/macros.rs`
* tx: add fn signatures
* output: fix fn signatures
* ops: expose `_inner()` functions
* block: add `add_block_header{_bulk, _inner}()`
* ops: remove doc_{fn,inner}!()`
* ops: remove `_{inner,bulk}()`, lifetime + generics
* update lib/mod docs
* ops: add and use `doc_add_block_inner_invariant!()`
* ops: add docs/return to inner `add_block()` functions
* add_block(): extract and use fn for {key_image, output}
* ops: more fn body impl + `add_block()`
* cargo: add `monero-pruning`
* ops: extract out `tx` functions from `add_block()`
* property: add `db_version()`
* ops: `pop_block()` body, remove other `pop_block` fn's
* types: add `block_blob: Vec<u8>` to `VerifiedBlockInformation`
* block: put `block_blob`, pass `Tables` to sub-functions
`impl TablesMut` can't mutably pass multiple tables since
it takes `&mut self`, so all functions unfortunately have to
take a full `&mut impl TablesMut` even though they only need
a few tables.
* database: add `DatabaseRw::take()`
useful for `pop_block()` where we need the value afterwards
* block: deserialize tx's from `block_blobs` in `pop_block()`
* blockchain: `height()` -> `chain_height()`
* output: fix `amount_index`
* ops: fix unlock_time, chain_height
* `BlockInfoV{1,2,3}` -> `BlockInfo`
* constants: add `DATABASE_VERSION`
* database: add `DatabaseRw::update()`
* output: use `DatabaseRw::update()` in `remove_output()`
* add `TxBlobs` table, ignore pruning tables
* block: mostly impl `add_block()` body
* ops: comments
* add_block: miner v2 tx commitment, height cast
* block: impl `pop_block()`
* block: mostly impl `get_block()`
* block: impl `get_block_{from_height,header,header_from_height}`
* add `OutputFlags` bitflags
* add_block: u32::try_into(height: u32), use `OutputFlags`
* tx: impl `get_{tx,tx_from_id}()`
* tx: move docs tests to `#[test]`
testing everything in 1 go is more natural since e.g:
`add_tx()` is followed by `get_tx()`
* tables: add `trait TablesIter`, `all_tables_empty()`
This allows `TablesMut` to be a superset of `Tables`
and use all its accessor functions.
* use cuprate-test-utils, fix tx tests
* block: `add_block()` take block by ref
* tx: use all txs in tests
* output: add `all_tx_functions()` test
* add_block: check current height against input
* block: map more fields in `get_block()`
* block: remove `get_block()`, doc tests, fix `get_block_header()`
* block: dummy values in test
* heed: use `last/first()` instead of `unsafe` cursors
We no longer have DUP semantics and also hard to debug errors
were popping up on `del_current()`...
* heed: fix `DatabaseRw::delete`
Ok(true) means the key did not exist, so we must return
Err(RuntimeError::KeyNotFound)
* block: `add_block()` (dummy value) test
* ops: `key_image` tests
* cleanup, docs, tests
* backend: test `take()` & `update()`
* docs
* remove `OutputFlags::NONE`
* add_block(): add asserts, panic docs, `should_panic` tests
* backend: remove `Ok(())` in `Database::delete` if already deleted
redb already does this, so heed so match
* block: move block operations after tx/outputs
* `amount == 0` -> `amount == 1`
* Nit: StorableVec::wrap_ref
* `saturating_sub(1)` -> `- 1`
* add `TxOutputs` table
* add_block(): add to `tx_outputs` table
* fix `DatabaseRo::update`
* add_tx(): take `block_height` as input
* tx: add/remove from `TxOutputs` table
* output: remove if `amount == 1` -> `amount_index == 0`
* output: fix `add_output()`'s `amount_index` calculation
* output: fix `add_output()`'s `amount_index` calculation again
* output: tests for `amount_index/num_outputs`
* block: `num_outputs - 1` and `take()` -> `get()`
We don't need to `take()` since the call afterwards to
`remove_output()` removes the entry
* block: swap `get_block_extended_header[_from_height]()`
* move `{key_image,output}` handling `add_block()` -> `add_tx()`
* blockchain: add doc to `top_block_height()`
* block: manual panic -> `assert_eq!()`
* test-utils: add `block_blob` to `VerifiedBlockInformation`
field introduced in this PR
* ops: use real block/tx data in tests
* block: `total_generated_coins` -> `cumulative_generated_coins`
* fix clippy, docs, TODOs
* `cumulative_generated_coins()`: `block/` -> `blockchain/`
* blockchain: add `cumulative_generated_coins()` tests
* Update database/src/ops/block.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* `cumulative_generated_coins()` docs for pre-block-0 special case
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-04-23 01:53:29 +00:00
|
|
|
|
2024-06-26 21:51:06 +00:00
|
|
|
/// Create a database table.
|
database: implement `ops/` (#102)
* ops: add `trait MoneroR{o,w}`
* update `trait MoneroR{o,w}` bounds
* types: add `BlockInfoLatest` type alias
* block: impl most core functions
* types: fix https://github.com/Cuprate/cuprate/pull/91#discussion_r1527668916
* fix table type test
* cargo.toml: add `{cuprate-types, monero-serai}`
* add_block: add all other block data
* ops: remove unneeded `block` functions
* env: add `EnvInner::open_db_rw_all()`
* types: fix test
* block: `&mut TxRw` -> `&TxRw`, use `open_db_rw_all()`
* add `trait Tables[Mut]` and use it in `EnvInner`
* block: use `TablesMut`
* tables: replace manual impl with `define_trait_tables!()`
* tables: docs for `trait Tables[Mut]`
* tables: doc functions
* create `call_fn_on_all_tables_or_early_return!()` macro
* block: cleanup signatures + bodies
* block: more fn's, docs
* block: add `doc_{error,single,bulk}!()`
* remove `ops/monero.rs`
* move `height()` to `ops/blockchain.rs`
* add `ops/macros.rs`
* tx: add fn signatures
* output: fix fn signatures
* ops: expose `_inner()` functions
* block: add `add_block_header{_bulk, _inner}()`
* ops: remove doc_{fn,inner}!()`
* ops: remove `_{inner,bulk}()`, lifetime + generics
* update lib/mod docs
* ops: add and use `doc_add_block_inner_invariant!()`
* ops: add docs/return to inner `add_block()` functions
* add_block(): extract and use fn for {key_image, output}
* ops: more fn body impl + `add_block()`
* cargo: add `monero-pruning`
* ops: extract out `tx` functions from `add_block()`
* property: add `db_version()`
* ops: `pop_block()` body, remove other `pop_block` fn's
* types: add `block_blob: Vec<u8>` to `VerifiedBlockInformation`
* block: put `block_blob`, pass `Tables` to sub-functions
`impl TablesMut` can't mutably pass multiple tables since
it takes `&mut self`, so all functions unfortunately have to
take a full `&mut impl TablesMut` even though they only need
a few tables.
* database: add `DatabaseRw::take()`
useful for `pop_block()` where we need the value afterwards
* block: deserialize tx's from `block_blobs` in `pop_block()`
* blockchain: `height()` -> `chain_height()`
* output: fix `amount_index`
* ops: fix unlock_time, chain_height
* `BlockInfoV{1,2,3}` -> `BlockInfo`
* constants: add `DATABASE_VERSION`
* database: add `DatabaseRw::update()`
* output: use `DatabaseRw::update()` in `remove_output()`
* add `TxBlobs` table, ignore pruning tables
* block: mostly impl `add_block()` body
* ops: comments
* add_block: miner v2 tx commitment, height cast
* block: impl `pop_block()`
* block: mostly impl `get_block()`
* block: impl `get_block_{from_height,header,header_from_height}`
* add `OutputFlags` bitflags
* add_block: u32::try_into(height: u32), use `OutputFlags`
* tx: impl `get_{tx,tx_from_id}()`
* tx: move docs tests to `#[test]`
testing everything in 1 go is more natural since e.g:
`add_tx()` is followed by `get_tx()`
* tables: add `trait TablesIter`, `all_tables_empty()`
This allows `TablesMut` to be a superset of `Tables`
and use all its accessor functions.
* use cuprate-test-utils, fix tx tests
* block: `add_block()` take block by ref
* tx: use all txs in tests
* output: add `all_tx_functions()` test
* add_block: check current height against input
* block: map more fields in `get_block()`
* block: remove `get_block()`, doc tests, fix `get_block_header()`
* block: dummy values in test
* heed: use `last/first()` instead of `unsafe` cursors
We no longer have DUP semantics and also hard to debug errors
were popping up on `del_current()`...
* heed: fix `DatabaseRw::delete`
Ok(true) means the key did not exist, so we must return
Err(RuntimeError::KeyNotFound)
* block: `add_block()` (dummy value) test
* ops: `key_image` tests
* cleanup, docs, tests
* backend: test `take()` & `update()`
* docs
* remove `OutputFlags::NONE`
* add_block(): add asserts, panic docs, `should_panic` tests
* backend: remove `Ok(())` in `Database::delete` if already deleted
redb already does this, so heed so match
* block: move block operations after tx/outputs
* `amount == 0` -> `amount == 1`
* Nit: StorableVec::wrap_ref
* `saturating_sub(1)` -> `- 1`
* add `TxOutputs` table
* add_block(): add to `tx_outputs` table
* fix `DatabaseRo::update`
* add_tx(): take `block_height` as input
* tx: add/remove from `TxOutputs` table
* output: remove if `amount == 1` -> `amount_index == 0`
* output: fix `add_output()`'s `amount_index` calculation
* output: fix `add_output()`'s `amount_index` calculation again
* output: tests for `amount_index/num_outputs`
* block: `num_outputs - 1` and `take()` -> `get()`
We don't need to `take()` since the call afterwards to
`remove_output()` removes the entry
* block: swap `get_block_extended_header[_from_height]()`
* move `{key_image,output}` handling `add_block()` -> `add_tx()`
* blockchain: add doc to `top_block_height()`
* block: manual panic -> `assert_eq!()`
* test-utils: add `block_blob` to `VerifiedBlockInformation`
field introduced in this PR
* ops: use real block/tx data in tests
* block: `total_generated_coins` -> `cumulative_generated_coins`
* fix clippy, docs, TODOs
* `cumulative_generated_coins()`: `block/` -> `blockchain/`
* blockchain: add `cumulative_generated_coins()` tests
* Update database/src/ops/block.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* `cumulative_generated_coins()` docs for pre-block-0 special case
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-04-23 01:53:29 +00:00
|
|
|
///
|
2024-07-01 19:24:48 +00:00
|
|
|
/// This will create the database [`Table`] passed as a generic to this function.
|
2024-05-05 14:21:28 +00:00
|
|
|
///
|
2024-06-26 21:51:06 +00:00
|
|
|
/// # Errors
|
|
|
|
/// This will only return [`RuntimeError::Io`] on errors.
|
2024-07-01 19:24:48 +00:00
|
|
|
///
|
|
|
|
/// # Invariant
|
|
|
|
#[doc = doc_heed_create_db_invariant!()]
|
2024-07-06 12:21:46 +00:00
|
|
|
fn create_db<T: Table>(&self, tx_rw: &Self::Rw<'_>) -> Result<(), RuntimeError>;
|
database: implement `ops/` (#102)
* ops: add `trait MoneroR{o,w}`
* update `trait MoneroR{o,w}` bounds
* types: add `BlockInfoLatest` type alias
* block: impl most core functions
* types: fix https://github.com/Cuprate/cuprate/pull/91#discussion_r1527668916
* fix table type test
* cargo.toml: add `{cuprate-types, monero-serai}`
* add_block: add all other block data
* ops: remove unneeded `block` functions
* env: add `EnvInner::open_db_rw_all()`
* types: fix test
* block: `&mut TxRw` -> `&TxRw`, use `open_db_rw_all()`
* add `trait Tables[Mut]` and use it in `EnvInner`
* block: use `TablesMut`
* tables: replace manual impl with `define_trait_tables!()`
* tables: docs for `trait Tables[Mut]`
* tables: doc functions
* create `call_fn_on_all_tables_or_early_return!()` macro
* block: cleanup signatures + bodies
* block: more fn's, docs
* block: add `doc_{error,single,bulk}!()`
* remove `ops/monero.rs`
* move `height()` to `ops/blockchain.rs`
* add `ops/macros.rs`
* tx: add fn signatures
* output: fix fn signatures
* ops: expose `_inner()` functions
* block: add `add_block_header{_bulk, _inner}()`
* ops: remove doc_{fn,inner}!()`
* ops: remove `_{inner,bulk}()`, lifetime + generics
* update lib/mod docs
* ops: add and use `doc_add_block_inner_invariant!()`
* ops: add docs/return to inner `add_block()` functions
* add_block(): extract and use fn for {key_image, output}
* ops: more fn body impl + `add_block()`
* cargo: add `monero-pruning`
* ops: extract out `tx` functions from `add_block()`
* property: add `db_version()`
* ops: `pop_block()` body, remove other `pop_block` fn's
* types: add `block_blob: Vec<u8>` to `VerifiedBlockInformation`
* block: put `block_blob`, pass `Tables` to sub-functions
`impl TablesMut` can't mutably pass multiple tables since
it takes `&mut self`, so all functions unfortunately have to
take a full `&mut impl TablesMut` even though they only need
a few tables.
* database: add `DatabaseRw::take()`
useful for `pop_block()` where we need the value afterwards
* block: deserialize tx's from `block_blobs` in `pop_block()`
* blockchain: `height()` -> `chain_height()`
* output: fix `amount_index`
* ops: fix unlock_time, chain_height
* `BlockInfoV{1,2,3}` -> `BlockInfo`
* constants: add `DATABASE_VERSION`
* database: add `DatabaseRw::update()`
* output: use `DatabaseRw::update()` in `remove_output()`
* add `TxBlobs` table, ignore pruning tables
* block: mostly impl `add_block()` body
* ops: comments
* add_block: miner v2 tx commitment, height cast
* block: impl `pop_block()`
* block: mostly impl `get_block()`
* block: impl `get_block_{from_height,header,header_from_height}`
* add `OutputFlags` bitflags
* add_block: u32::try_into(height: u32), use `OutputFlags`
* tx: impl `get_{tx,tx_from_id}()`
* tx: move docs tests to `#[test]`
testing everything in 1 go is more natural since e.g:
`add_tx()` is followed by `get_tx()`
* tables: add `trait TablesIter`, `all_tables_empty()`
This allows `TablesMut` to be a superset of `Tables`
and use all its accessor functions.
* use cuprate-test-utils, fix tx tests
* block: `add_block()` take block by ref
* tx: use all txs in tests
* output: add `all_tx_functions()` test
* add_block: check current height against input
* block: map more fields in `get_block()`
* block: remove `get_block()`, doc tests, fix `get_block_header()`
* block: dummy values in test
* heed: use `last/first()` instead of `unsafe` cursors
We no longer have DUP semantics and also hard to debug errors
were popping up on `del_current()`...
* heed: fix `DatabaseRw::delete`
Ok(true) means the key did not exist, so we must return
Err(RuntimeError::KeyNotFound)
* block: `add_block()` (dummy value) test
* ops: `key_image` tests
* cleanup, docs, tests
* backend: test `take()` & `update()`
* docs
* remove `OutputFlags::NONE`
* add_block(): add asserts, panic docs, `should_panic` tests
* backend: remove `Ok(())` in `Database::delete` if already deleted
redb already does this, so heed so match
* block: move block operations after tx/outputs
* `amount == 0` -> `amount == 1`
* Nit: StorableVec::wrap_ref
* `saturating_sub(1)` -> `- 1`
* add `TxOutputs` table
* add_block(): add to `tx_outputs` table
* fix `DatabaseRo::update`
* add_tx(): take `block_height` as input
* tx: add/remove from `TxOutputs` table
* output: remove if `amount == 1` -> `amount_index == 0`
* output: fix `add_output()`'s `amount_index` calculation
* output: fix `add_output()`'s `amount_index` calculation again
* output: tests for `amount_index/num_outputs`
* block: `num_outputs - 1` and `take()` -> `get()`
We don't need to `take()` since the call afterwards to
`remove_output()` removes the entry
* block: swap `get_block_extended_header[_from_height]()`
* move `{key_image,output}` handling `add_block()` -> `add_tx()`
* blockchain: add doc to `top_block_height()`
* block: manual panic -> `assert_eq!()`
* test-utils: add `block_blob` to `VerifiedBlockInformation`
field introduced in this PR
* ops: use real block/tx data in tests
* block: `total_generated_coins` -> `cumulative_generated_coins`
* fix clippy, docs, TODOs
* `cumulative_generated_coins()`: `block/` -> `blockchain/`
* blockchain: add `cumulative_generated_coins()` tests
* Update database/src/ops/block.rs
Co-authored-by: Boog900 <boog900@tutanota.com>
* `cumulative_generated_coins()` docs for pre-block-0 special case
---------
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-04-23 01:53:29 +00:00
|
|
|
|
database: add more `fn` to `trait DatabaseR{o,w}` (#96)
* database: add more fn signatures
* database: fix docs
* heed: add new fn signatures with `todo!()`
* heed: add shared fn sigantures
* database: make `iter()` return `(key, value)`
* database: make `get_range()` return `(key, value)`
* database: make `first()/last()` return `(key, value)`
* heed: impl new fn signatures
* redb: impl new fn signatures
* backend: update tests for new `fn`s
* backend: update table tests
* heed: fix `retain()` predicate behavior
* database: add `keys()`, `values()`, `pop_first()`, `pop_last()`
* heed: impl `keys()`, `values()`, `pop_first()`, `pop_last()`
* redb: impl `keys()`, `values()`, `pop_first()`, `pop_last()`
* database: add `contains()`
* backend: add `contains()` to tests
* database: remove `retain()`
* database: only return value in `get_range()`
* database: `DatabaseRw::clear()` -> `EnvInner::clear_db()`
* redb: update `clear_db()` invariant doc
* fix redb
* cargo.toml: avoid merge conflict
* update `get_range()` docs
* redb: re-create table in `clear_db()`
2024-03-30 01:33:38 +00:00
|
|
|
/// Clear all `(key, value)`'s from a database table.
|
|
|
|
///
|
|
|
|
/// This will delete all key and values in the passed
|
|
|
|
/// `T: Table`, but the table itself will continue to exist.
|
|
|
|
///
|
|
|
|
/// Note that this operation is tied to `tx_rw`, as such this
|
|
|
|
/// function's effects can be aborted using [`TxRw::abort`].
|
|
|
|
///
|
2024-07-01 19:24:48 +00:00
|
|
|
/// # Errors
|
|
|
|
/// This will return [`RuntimeError::Io`] on normal errors.
|
|
|
|
///
|
|
|
|
/// If the specified table is not created upon before this function is called,
|
|
|
|
/// this will return [`RuntimeError::TableNotFound`].
|
2024-07-06 12:21:46 +00:00
|
|
|
fn clear_db<T: Table>(&self, tx_rw: &mut Self::Rw<'_>) -> Result<(), RuntimeError>;
|
Database (#35)
* rename `database` -> `old_database`
Keeping it around for reference until new implementation is complete.
* create new `database/` skeleton
* add `DATABASE.md` design doc skeleton
* move design doc to `database/README.md`
* add rough code
* `lib.rs` -> `gist.rs`
* database: use workspace deps
* workspace: include `database/` as member
CI will now include this crate.
* cargo fmt
* database: `AGPL` -> `MIT`
* readme: add `TODO`s
* add base files
* cargo.toml: add `heed` feature
* fix clippy
* lib.rs: add extremely pedantic lints
* readme: add `# Backends`
* cargo.toml: add `cfg-if`
* add `backend/` structure
* base `database.rs`
* cargo.toml: add `borsh`
* backend: add `DATABASE_BACKEND`
* base `error.rs`
* base `database.rs`
* base `transaction.rs`
* base `table.rs`
* lib.rs: add imports
* add `pod.rs`
* pod: use `Read/Write`, add tests for all primitive numbers
* pod: impl Pod for `Vec<u8>`, `[u8; N]`
* pod: add docs, add `private::Sealed`
* pod: `to_writer`, `from_reader`
The new `as_bytes` + `from_bytes` now allows (de)serializing from
bytes directly instead of going through Read/Write.
Different array return sizes are abstracted away with `-> impl AsRef<[u8]>`
* pod: impl Pod for `Box<[u8]>`
* pod: return `Err` on incorrect length in `from_bytes()`
* pod: docs
* pod: impl Pod for `Arc<[u8]>`
* readme: docs
* database: add `create_table()`, `get_table()`
* table: `Pod` bound
* backend: move into directories
* pod: add `into_bytes()`
* heed: impl `BytesEncode`, `BytesDecode`
* add `actor`, `service` features
The thread/actor system used will be gated behind `actor`,
and the `tower/tokio` integration will be gated behind `service`.
* add `lib.rs` docs
* service: add `service.rs`
* service: add `reader.rs`
* service: add `writer.rs`
* service: add `request.rs` & `response.rs`
* cargo.toml: add `crossbeam`
* service: add/use `enum Request`, `enum Response`
* service: basic signatures for thread-pools, `Writer` -> `Writers`
* service: split `tower::Service<ReadRequest/WriteRequest>`
* service: impl `tower::Service` for `Database(Reader|Writer)`
* service: add `init()`, impl basic `Reader/Writer` pools
* service: add example `Request`'s
* service: add example `ReadRequest` handling
* temporarily allow clippy lints
* readme: update file structure
* transaction: add `RoTx::get_range()`
* service: module docs
* cargo.toml: add `cuprate-helper`
* service: scale readers/writers based on thread count
* database: change lifetimes
* heed: impl Database for `heed`
* heed: add `ConcreteRoTx`, `ConcreteRwTx`, impl Tx traits
* docs
* service: `read.rs` docs
* service: `write.rs` docs
* service: request/response docs
* service: use `OnceLock` in `init()`, add `db_read()`, `db_write()`
* service: leak database into `&'static`
* database: add `#[inline]`, `#[cold]`
* service: `free.rs` docs, more `#[inline]` + `#[cold]`
* service: add `shutdown()`
* service: add `Request::Shutdown`
* service: `shutdown()` docs
* heed: hide concrete tx types
* lib.rs: add terms
* split `Env` <-> `Database`
* cargo.toml: add `paste`
* database: add `tables/`
* impl `serde/borsh` where possible
* tables: add `Tables`, add test docs
* make db backend mutually exclusive to fix `--all-features`
* tables: use `$()*` in `tables!()`
* cargo.toml: add `sanakirja 1.4.0`
* sanakirja: impl `Env`
* sanakirja: impl `Database`
* sanakirja: impl `Transaction`
* table: temporarily fix `sanakirja` K/V bounds
* table: fix `#[cfg]`
* cargo.toml: fix deps
* lib.rs: docs
* service: docs
* readme: add files, update `# Documentation`, add `# Layers`
* readme: `src/` file purpose
* readme: `src/service/` file purpose
* readme: `src/backend/` file purpose
* fix `Cargo.lock` merge conflict
* database: remove `gist.rs`
* add to `constants.rs`
* add top `//! comments` for files/modules
* constants: add sanity-check test
* service: add `only_one_database` test in `free.rs`
* service: add `tests.rs`
* remove unneeded markers + imports
* backend: fix `get_range()`'s trait `impl` return
* env: add `create_tables_if_needed()`, don't return `Option<Db>`
* sort imports by `CONTRIBUTING.md` rules
oops sorry boog
* add `monero.rs`
* monero: docs
* database: add missing `RoTx/RwTx` inputs
* backend: add missing `RoTx/RwTx` inputs
* `monero.rs` trait -> free functions in `ops/`
* pod: make methods infallible
* ci: add `rustup update` step
* service: use `Arc` instead of leaking, remove `db_read/db_write`
* service: use `InfallibleOneshotReceiver` for readers
* service: shutdown on error, add todos
* service: remove `Request`
* service: combine `ReadResponse` and `WriteResponse`
* service: use `InfallibleOneshotReceiver` for writer
* service: only spawn 1 writer, don't allow cloning writer handle
* table: add associated `const CONSTANT_SIZE`
* add `key.rs` + `trait Key`, add bound to `Table`
* fix typos
2024-02-13 17:43:25 +00:00
|
|
|
}
|