Skip to content

Allow path stitcher to work on SQLiteReader #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions stack-graphs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- The `Appendable` trait has been simplified. Its `Ctx` type parameter is gone, in favor of a separate trait `ToAppendable` that is used to find appendables for a handle. The type itself moved from the `cycles` to the `stitching` module.
- The `ForwardPartialPathStitcher` has been generalized so that it can be used to build paths from a database or from graph edges. It now takes a type parameter indicating the type of candidates it uses. Instead of a `Database` instance, it expects a value that implements the `Candidates` and `ToAppendable` traits. The `ForwardPartialPathStitcher::process_next_phase` expects an additional `extend_until` closure that controls whether the extended paths are considered for further extension or not (using `|_,_,_| true` retains old behavior).
- The `ForwardPartialPathStitcher` has been generalized so that it can be used to build paths from a database, graph edges, or a SQL reader. It now takes a type parameter indicating the type of candidates it uses. Instead `StackGraph`, `PartialPaths` and `Database` instances, it expects a value that implements the `ForwardCandidates` trait. The `ForwardPartialPathStitcher::process_next_phase` expects an additional `extend_until` closure that controls whether the extended paths are considered for further extension or not (using `|_,_,_| true` retains old behavior).
- The SQLite database implementation is using a new schema which stores binary instead of JSON values, resulting in faster write times and smaller databases.
- Renamed method `SQLiteReader::load_graph_for_file_or_directory` to `SQLiteReader::load_graphs_for_file_or_directory`.

Expand All @@ -30,7 +30,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- The `ForwardPartialPathStitcher::from_nodes` function has been removed. Callers are responsible for creating the right initial paths, which can be done using `PartialPath::from_node`.
- The `PartialPaths::find_minimal_partial_path_set_in_file` method has been removed in favor of `ForwardPartialPathStitcher::find_minimal_partial_path_set_in_file`.
- The `PartialPaths::find_all_complete_paths` method has been removed in favor of `ForwardPartialPathStitcher::find_all_complete_partial_paths` using `GraphEdges(None)` for the `db` argument.
- The `PartialPaths::find_all_complete_paths` method has been removed in favor of `ForwardPartialPathStitcher::find_all_complete_partial_paths` using a `GraphEdgeCandidates` instance for the `candidates` argument.
- The `Database::find_all_complete_paths` method has been removed in favor of `ForwardPartialPathStitcher::find_all_complete_partial_paths` using a `DatabaseCandidates` instance for the `candidates` argument.
- The `SQLiteReader::find_all_complete_partial_paths` method has been removed in favor of `ForwardPartialPathStitcher::find_all_complete_partial_paths` using a `SQLiteReader` instance for the `candidates` argument.
- The `OwnedOrDatabasePath` has been removed because it was obsolete with the changes to `Appendable`.

## v0.11.0 -- 2023-06-08
Expand Down
5 changes: 2 additions & 3 deletions stack-graphs/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::graph::Symbol;
use crate::partial::PartialPath;
use crate::partial::PartialPaths;
use crate::stitching::Database;
use crate::stitching::DatabaseCandidates;
use crate::stitching::ForwardPartialPathStitcher;
use crate::CancellationError;
use crate::CancellationFlag;
Expand Down Expand Up @@ -179,9 +180,7 @@ impl Assertion {
for reference in &references {
let mut reference_paths = Vec::new();
ForwardPartialPathStitcher::find_all_complete_partial_paths(
graph,
partials,
db,
&mut DatabaseCandidates::new(graph, partials, db),
vec![*reference],
cancellation_flag,
|_, _, p| {
Expand Down
14 changes: 7 additions & 7 deletions stack-graphs/src/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ use crate::partial::PartialScopeStack;
use crate::partial::PartialScopedSymbol;
use crate::partial::PartialSymbolStack;
use crate::stitching::Database;
use crate::stitching::DatabaseCandidates;
use crate::stitching::ForwardPartialPathStitcher;
use crate::stitching::GraphEdges;
use crate::stitching::GraphEdgeCandidates;
use crate::CancellationError;
use crate::CancellationFlag;

Expand Down Expand Up @@ -1218,9 +1219,7 @@ pub extern "C" fn sg_partial_path_arena_find_all_complete_paths(
let cancellation_flag: Option<&AtomicUsize> =
unsafe { std::mem::transmute(cancellation_flag.as_ref()) };
ForwardPartialPathStitcher::find_all_complete_partial_paths(
graph,
partials,
&mut GraphEdges(None),
&mut GraphEdgeCandidates::new(graph, partials, None),
starting_nodes.iter().copied().map(sg_node_handle::into),
&AtomicUsizeCancellationFlag(cancellation_flag),
|graph, _partials, path| {
Expand Down Expand Up @@ -1535,9 +1534,10 @@ pub extern "C" fn sg_forward_partial_path_stitcher_process_next_phase(
let partials = unsafe { &mut (*partials).inner };
let db = unsafe { &mut (*db).inner };
let stitcher = unsafe { &mut *(stitcher as *mut InternalForwardPartialPathStitcher) };
stitcher
.stitcher
.process_next_phase(graph, partials, db, |_, _, _| true);
stitcher.stitcher.process_next_phase(
&mut DatabaseCandidates::new(graph, partials, db),
|_, _, _| true,
);
stitcher.update_previous_phase_partial_paths(partials);
}

Expand Down
Loading