Files
Mazdak Farrokhzad 8348151915 define SmallHashMap in spacetimedb_data_structures (#4136)
# Description of Changes

Defines `SmallHashMap` in `spacetimedb_data_structures`.
The data structure is a hybrid map that is backed by a vector and linear
scan for the first `M` elements.
Then it falls back into a normal hash map.
For the first `N` elements, where `N < M`, the vector is stored inline.
That is, the vector is a `SmallVec<[(K, V); N>`.
The structure is optimized for access patterns where the keys and values
are accessed together,
therefore, keys and values are not stored separately.

# API and ABI breaking changes

None, just additive.

# Expected complexity level and risk

1

# Testing

A comprehensive proptest suite is added for the datastructure.
2026-01-27 15:15:23 +00:00

29 lines
730 B
TOML

[package]
name = "spacetimedb-data-structures"
version.workspace = true
edition.workspace = true
license-file = "LICENSE"
description = "Assorted data structures used in spacetimedb"
rust-version.workspace = true
[features]
memory-usage = ["dep:spacetimedb-memory-usage"]
serde = ["dep:serde", "hashbrown/serde"]
[dependencies]
spacetimedb-memory-usage = { workspace = true, optional = true, default-features = false }
ahash.workspace = true
crossbeam-queue.workspace = true
either.workspace = true
hashbrown.workspace = true
nohash-hasher.workspace = true
serde = { workspace = true, optional = true }
smallvec.workspace = true
thiserror.workspace = true
[dev-dependencies]
proptest.workspace = true
[lints]
workspace = true