- Refactor `bindings::query::delete_by_field` to require `FilterableValue`
and return `u32` count of deleted rows.
- Add `bindings::query::delete_by_unique_field`
with the previous behavior of `delete_by_field`,
i.e. requiring `UniqueValue` and returning `bool` with `true = deleted`.
This is implemented in terms of `delete_by_field`.
- Macro-generated unique filter funcs call `delete_by_unique_field`
rather than `delete_by_field`.
- The table macro now generates non-unique delete functions
alongside the existing non-unique filter functions
for non-unique fields with primitive types.
- Add uses of `::delete_by_{field}` for both unique and non-unique columns
to the `rust-wasm-test` module.
Note that this PR does not include any host-side changes;
the diff is localized to the `bindings` and `bindings-macro` crates.
When building a release for a tag we have to build a multi arch image
ourselves. So far we tagged it with a tag `<short-sha>-full`. This is
nice to keep the history of all the tagged commits, but it's not very
usable as usually we just want the latest build for a given tag. This
commit introduces tagging the build with a git tag
Compare `TableSchema` instead of `TableDef`, which should reject all
modifications to a table. Note that the values require conversion for
both the module and database schema to be comparable.
With this change, updating a module which only adds tables or modifies
reducers will be possible, but any change (including indexes,
constraints, etc) to an existing table will fail the update.
I seem to be unable to build `core` directly on master,
though building the workspace root, i.e. `cli`, works.
This is caused by `core` depending on `spacetimedb-lib.workspace`,
which has `default-features = false`, excluding serde support.
This commit correctly specifies the `"serde"` feature for core's dependency on lib,
so it is now possible to `cd crates/core && cargo check`.
* Adding game loading benchmarks
* Change the dat load to use 1_000_000 for both tables
* Move subscription benchmarks alongside incremental ones
* Update README
---------
Co-authored-by: Mario Alejandro Montoya Cortés <mamcx@elmalabarista.com>
Closes#836.
The tracing library does not fully remove all instrumentation at compile time.
And since tracing is not zero cost,
it must be removed from the hot path of query execution.
Prior to this commit, `ScanIterByColRange::next` called `RowRef::to_product_value`
and then `ProductValue::project_not_empty` on every row in the table
to get a key, which it compared to the sought range.
This always allocated at least a `ProductValue`,
even when seeking a range of primitive type like `u64`.
It also unnecessarily deserialized (and potentially allocated)
columns not relevant to the search for rows which did not match the range.
With this commit, we call `RowRef::project_not_empty` directly.
When the sought range is a single column, this avoids allocating a `ProductValue`.
Even when seeking a multi-column range, this avoids deserializing unrelated columns
of non-matching rows.
Non-indexed `IterByColEq` is always going to be slow, so this probably doesn't matter,
but it's a trivial change.
* This fixes replaying of the transaction log to no longer check constraints
* Fixed based on Phoebe and Kim's comments
* Cargo fmt
* Cargo fmt
* This fixes index updating for replaying deletes
---------
Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
* BTreeIndex: Specialize on primitive key types for great performance
Rewrite of Tyler's #771, because I thought this would be easier than rebasing.
This commit hoists branching on key types outside of comparisons and searches
in `BTreeIndex`,
so that in many cases we can use e.g. `u64::cmp`
instead of the much slower `AlgebraicValue::cmp`.
This design is kind of ugly, and will likely change in the future,
but for now it's good enough, and is a meaningful performance improvement.
* BTreeIndex: use `ReadColumn` instead of `ProductValue` fields
Prior to this commit, `BTreeIndex::insert` and `BTreeIndex::delete`
took a `&ProductValue`, the row to be inserted or deleted, as an argument,
and extracted the indexed column value(s) from it.
With this commit, we instead take a `RowRef`
referring to the row to be inserted or deleted,
and access the indexed column value(s) using `ReadColumn`.
For specialized indexes, we extract them directly as native types,
rather than as `AlgebraicValue`.
Making this change involved a nasty split borrow problem,
as we now need to have a `RowRef` to the inserted/deleted row
coexisting with a mutable borrow of the index to be modified.
This required introducing a `TableInner` struct,
which is the referent of `RowRef`.
* Lints: superfluous borrows
Rewrite of Tyler's #771, because I thought this would be easier than rebasing.
This commit hoists branching on key types outside of comparisons and searches
in `BTreeIndex`,
so that in many cases we can use e.g. `u64::cmp`
instead of the much slower `AlgebraicValue::cmp`.
This design is kind of ugly, and will likely change in the future,
but for now it's good enough, and is a meaningful performance improvement.
This commit defines `trait ReadColumn`,
which is implemented for types that can be stored in a table column
and can be read out of said table column.
Its interesting method is
`read_column(row: RowRef<'_>, idx: usize) -> Result<Self, TypeError>`,
which attempts to read the `idx`th column of `row` as a value of type `Self`,
returning a `TypeError` if the row in question does not have the appropriate types.
`ReadColumn` is implemented for Rust equivalents of all non-compound `AlgebraicType`s,
i.e. integers, floats, `bool` and `String`.
It is also implemented for all SATS value types,
including those which represent values of compound types,
i.e. `AlgebraicValue`, `ProductValue`, `SumValue`, `ArrayValue` and `MapValue`.