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

Method truncate

nodedb/src/engine/kv/engine_stats.rs:91–103  ·  view source on GitHub ↗

Truncate: delete all entries in a KV collection. Returns count deleted.

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

Source from the content-addressed store, hash-verified

89
90 /// Truncate: delete all entries in a KV collection. Returns count deleted.
91 pub fn truncate(&mut self, tenant_id: u64, collection: &str) -> usize {
92 let tkey = table_key(tenant_id, collection);
93 let count = self.tables.get(&tkey).map(|t| t.len()).unwrap_or(0);
94
95 // Remove the hash table entirely.
96 self.tables.remove(&tkey);
97 // Remove all indexes.
98 self.indexes.remove(&tkey);
99 // Note: expiry wheel entries for this collection will be no-ops
100 // when they fire (key won't be found in the hash table).
101
102 count
103 }
104
105 // -----------------------------------------------------------------------
106 // Stats

Callers 15

pending_segmentsMethod · 0.45
rollback_toMethod · 0.45
list_checkpointsMethod · 0.45
enforce_cursor_limitFunction · 0.45
rollback_to_savepointMethod · 0.45
executeFunction · 0.45
apply_rls_filterFunction · 0.45
replay_kv_walMethod · 0.45
execute_grouping_setsFunction · 0.45
execute_insert_selectMethod · 0.45
execute_aggregateMethod · 0.45

Calls 4

table_keyFunction · 0.85
getMethod · 0.45
lenMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected