Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions crates/flow/src/incremental/invalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,13 @@ impl InvalidationDetector {
fn tarjan_dfs(&self, v: &Path, state: &mut TarjanState, sccs: &mut Vec<Vec<PathBuf>>) {
// Initialize node
let index = state.index_counter;
state.indices.insert(v.to_path_buf(), index);
state.lowlinks.insert(v.to_path_buf(), index);

let v_owned = v.to_path_buf();
state.indices.insert(v_owned.clone(), index);
state.lowlinks.insert(v_owned.clone(), index);
state.index_counter += 1;
state.stack.push(v.to_path_buf());
state.on_stack.insert(v.to_path_buf());
state.stack.push(v_owned.clone());
state.on_stack.insert(v_owned);

// Visit all successors (dependencies)
let dependencies = self.graph.get_dependencies(v);
Expand All @@ -358,19 +360,19 @@ impl InvalidationDetector {

// Update lowlink
let w_lowlink = *state.lowlinks.get(dep).unwrap();
let v_lowlink = state.lowlinks.get_mut(&v.to_path_buf()).unwrap();
let v_lowlink = state.lowlinks.get_mut(v).unwrap();
*v_lowlink = (*v_lowlink).min(w_lowlink);
} else if state.on_stack.contains(dep) {
// Successor is on stack (part of current SCC)
let w_index = *state.indices.get(dep).unwrap();
let v_lowlink = state.lowlinks.get_mut(&v.to_path_buf()).unwrap();
let v_lowlink = state.lowlinks.get_mut(v).unwrap();
*v_lowlink = (*v_lowlink).min(w_index);
}
}

// If v is a root node, pop the stack to create an SCC
let v_index = *state.indices.get(&v.to_path_buf()).unwrap();
let v_lowlink = *state.lowlinks.get(&v.to_path_buf()).unwrap();
let v_index = *state.indices.get(v).unwrap();
let v_lowlink = *state.lowlinks.get(v).unwrap();

if v_lowlink == v_index {
let mut scc = Vec::new();
Expand Down
Loading