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

Method purge_tenant

nodedb/src/engine/kv/engine.rs:144–160  ·  view source on GitHub ↗

Remove all hash tables and indexes belonging to a specific tenant. Uses the `hash_to_tenant` reverse map to identify which tables belong to the tenant. Returns the number of tables removed.

(&mut self, tenant_id: u64)

Source from the content-addressed store, hash-verified

142 /// Uses the `hash_to_tenant` reverse map to identify which tables belong
143 /// to the tenant. Returns the number of tables removed.
144 pub fn purge_tenant(&mut self, tenant_id: u64) -> usize {
145 let keys_to_remove: Vec<u64> = self
146 .hash_to_tenant
147 .iter()
148 .filter(|(_, tid)| **tid == tenant_id)
149 .map(|(hash, _)| *hash)
150 .collect();
151
152 let removed = keys_to_remove.len();
153 for key in &keys_to_remove {
154 self.tables.remove(key);
155 self.indexes.remove(key);
156 self.hash_to_tenant.remove(key);
157 self.hash_to_collection.remove(key);
158 }
159 removed
160 }
161
162 // -----------------------------------------------------------------------
163 // Core operations

Callers 1

execute_purge_tenantMethod · 0.45

Calls 4

collectMethod · 0.80
iterMethod · 0.45
lenMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected