forked from kent/consciousness
store: add reindex_relations for after Vec mutations
- Add index::clear_relations() to drop and recreate RELS table - Add Store::reindex_relations() to rebuild index from Vec - Call reindex_relations() at end of dedup command This ensures index stays in sync with Vec after complex mutations like UUID redirection in dedup. Vec mutations remain for now but index is correctly updated afterward. Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
58b0947625
commit
c2de14dcab
3 changed files with 27 additions and 2 deletions
|
|
@ -209,6 +209,18 @@ pub fn remove_relation(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Clear all relations from the index.
|
||||
pub fn clear_relations(db: &Database) -> Result<()> {
|
||||
let txn = db.begin_write()?;
|
||||
{
|
||||
// Drop and recreate the table
|
||||
txn.delete_multimap_table(RELS)?;
|
||||
let _ = txn.open_multimap_table(RELS)?;
|
||||
}
|
||||
txn.commit()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get all edges for a node. Returns (other_uuid, strength, rel_type, is_outgoing).
|
||||
pub fn edges_for_node(db: &Database, node_uuid: &[u8; 16]) -> Result<Vec<([u8; 16], f32, u8, bool)>> {
|
||||
let txn = db.begin_read()?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue