store: filter deleted relations from graph building and snapshots
for_each_relation() was iterating deleted relations, polluting the graph with ghost edges. Also filter them from rkyv snapshots and clean them from the in-memory vec after cap_degree pruning.
This commit is contained in:
parent
a36449032c
commit
e33328e515
1 changed files with 6 additions and 1 deletions
|
|
@ -356,6 +356,7 @@ impl StoreView for Store {
|
|||
|
||||
fn for_each_relation<F: FnMut(&str, &str, f32, RelationType)>(&self, mut f: F) {
|
||||
for rel in &self.relations {
|
||||
if rel.deleted { continue; }
|
||||
f(&rel.source_key, &rel.target_key, rel.strength, rel.rel_type);
|
||||
}
|
||||
}
|
||||
|
|
@ -431,6 +432,7 @@ impl StoreView for MmapView {
|
|||
fn for_each_relation<F: FnMut(&str, &str, f32, RelationType)>(&self, mut f: F) {
|
||||
let snap = self.snapshot();
|
||||
for rel in snap.relations.iter() {
|
||||
if rel.deleted { continue; }
|
||||
let rt = match rel.rel_type {
|
||||
ArchivedRelationType::Link => RelationType::Link,
|
||||
ArchivedRelationType::Causal => RelationType::Causal,
|
||||
|
|
@ -752,7 +754,7 @@ impl Store {
|
|||
fn save_snapshot_inner(&self) -> Result<(), String> {
|
||||
let snap = Snapshot {
|
||||
nodes: self.nodes.clone(),
|
||||
relations: self.relations.clone(),
|
||||
relations: self.relations.iter().filter(|r| !r.deleted).cloned().collect(),
|
||||
gaps: self.gaps.clone(),
|
||||
params: self.params.clone(),
|
||||
};
|
||||
|
|
@ -1485,6 +1487,9 @@ impl Store {
|
|||
self.append_relations(&pruned_rels)?;
|
||||
}
|
||||
|
||||
// Remove deleted relations from in-memory vec so save() is clean
|
||||
self.relations.retain(|r| !r.deleted);
|
||||
|
||||
Ok((hubs_capped, to_delete.len()))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue