forked from kent/consciousness
store: convert more callers to use RELS index
Convert remaining Vec users to index-based access: - memory.rs: MemoryNode::from_store uses Store::neighbors() - graph.rs: orphan detection uses for_each_relation - local.rs: normalize_strengths uses for_each_relation + set_link_strength Add Store::neighbors() method and index::get_offsets_for_uuid(). Cleanup: - for_each_relation: build both uuid↔key maps in one pass - cap_degree: consolidate key/uuid/degree collection Remaining Vec uses: admin.rs (fsck, dedup), capnp.rs (load path). Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
5fe51fbfda
commit
5832e57970
8 changed files with 109 additions and 81 deletions
|
|
@ -176,12 +176,6 @@ pub fn apply_digest_links(store: &mut Store, links: &[DigestLink]) -> (usize, us
|
|||
|
||||
if source == target { skipped += 1; continue; }
|
||||
|
||||
// Check if link already exists
|
||||
let exists = store.relations.iter().any(|r|
|
||||
r.source_key == source && r.target_key == target && !r.deleted
|
||||
);
|
||||
if exists { skipped += 1; continue; }
|
||||
|
||||
let source_uuid = match store.get_node(&source).ok().flatten() {
|
||||
Some(n) => n.uuid,
|
||||
None => { skipped += 1; continue; }
|
||||
|
|
@ -191,6 +185,12 @@ pub fn apply_digest_links(store: &mut Store, links: &[DigestLink]) -> (usize, us
|
|||
None => { skipped += 1; continue; }
|
||||
};
|
||||
|
||||
// Check if link already exists via index
|
||||
let exists = store.neighbors(&source).ok()
|
||||
.map(|n| n.iter().any(|(k, _)| k == &target))
|
||||
.unwrap_or(false);
|
||||
if exists { skipped += 1; continue; }
|
||||
|
||||
let rel = new_relation(
|
||||
source_uuid, target_uuid,
|
||||
store::RelationType::Link,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue