MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / table_key

Function table_key

nodedb/src/engine/kv/engine_helpers.rs:10–12  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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).
10pub(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.

Callers 15

register_sorted_indexMethod · 0.85
sorted_index_on_putMethod · 0.85
has_sorted_indexesMethod · 0.85
tick_expiryMethod · 0.85
truncateMethod · 0.85
collection_lenMethod · 0.85
collection_mem_usageMethod · 0.85
incrMethod · 0.85
incr_floatMethod · 0.85
casMethod · 0.85
getsetMethod · 0.85

Calls 2

fxhash_multiFunction · 0.85
as_bytesMethod · 0.45

Tested by 2

on_put_updates_indexFunction · 0.68