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)
| 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 | /// |