clockworklabs / SpacetimeDB

Multiplayer at the speed of light
https://spacetimedb.com
Other
4.41k stars 110 forks source link

Rust SDK: Actual client-side indices for unique constraints #1909

Open gefjon opened 3 weeks ago

gefjon commented 3 weeks ago

Description of Changes

Based on #1900 , which in turn is based on #1897 .

Updates unique constraint .find methods on clients to be backed by actual indices, rather than O(n) full scans. Specifically, unique indices on clients are HashMaps, whereas on the server they are BTreeMaps. This is because:

Associated changes:

API and ABI breaking changes

Rust SDK codegen changes and will require re-running spacetime generate. Unique filter methods on columns of non-filterable types which were erroneously generated prior to now are no longer generated, so clients which depend on them will break.

Expected complexity level and risk

2 - codegen's always fiddly, but slapping a few extra HashMaps around is pretty simple.

Testing