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

Method ensure_table

nodedb/src/engine/kv/engine_atomic.rs:296–312  ·  view source on GitHub ↗

Ensure a hash table exists for (tenant, collection), creating if needed. Returns a mutable reference to the table.

(&mut self, tkey: u64, tenant_id: u64, collection: &str)

Source from the content-addressed store, hash-verified

294 /// Ensure a hash table exists for (tenant, collection), creating if needed.
295 /// Returns a mutable reference to the table.
296 fn ensure_table(&mut self, tkey: u64, tenant_id: u64, collection: &str) -> &mut KvHashTable {
297 if !self.tables.contains_key(&tkey) {
298 self.hash_to_tenant.entry(tkey).or_insert(tenant_id);
299 self.hash_to_collection
300 .entry(tkey)
301 .or_insert_with(|| collection.to_string());
302 self.tables.entry(tkey).or_insert_with(|| {
303 KvHashTable::new(
304 self.default_capacity,
305 self.load_factor_threshold,
306 self.rehash_batch_size,
307 self.inline_threshold,
308 )
309 });
310 }
311 self.tables.get_mut(&tkey).expect("just ensured")
312 }
313
314 /// Internal helper: put a value into the hash table, handling TTL and expiry.
315 ///

Callers 4

incrMethod · 0.80
incr_floatMethod · 0.80
casMethod · 0.80
getsetMethod · 0.80

Calls 4

entryMethod · 0.80
to_stringMethod · 0.80
expectMethod · 0.45
get_mutMethod · 0.45

Tested by

no test coverage detected