Key encoding and field extraction helpers for the KV engine. Compute a numeric key for per-collection HashMap lookups. Uses FxHash on `(tenant_id, collection)` to produce a `u64` — zero allocation, O(1). Replaces the old `format!("{tenant_id}:{collection}")` which allocated a String on every call (23% of PUT time was malloc/free).
(tenant_id: u64, collection: &str)
| 8 | /// O(1). Replaces the old `format!("{tenant_id}:{collection}")` which allocated |
| 9 | /// a String on every call (23% of PUT time was malloc/free). |
| 10 | pub(super) fn table_key(tenant_id: u64, collection: &str) -> u64 { |
| 11 | super::hash_helpers::fxhash_multi(&[&tenant_id.to_le_bytes(), b":", collection.as_bytes()]) |
| 12 | } |
| 13 | |
| 14 | /// Construct a composite key for the expiry wheel: "{tenant_id}:{collection}\0{key_bytes}". |
| 15 | /// The null byte separator is safe because collection names can't contain null. |