feat: CSR adjacency index for native graph traversal#160
Open
jja725 wants to merge 3 commits into
Open
Conversation
Add a Compressed Sparse Row (CSR) index that enables O(1) neighbor lookup for graph traversal, replacing SQL join-based expansion with direct pointer-chasing. Inspired by GraphAr's CSR-in-Parquet approach. Includes: - CsrIndex: in-memory CSR with neighbor lookup, BFS, shortest path - CsrIndexBuilder: construct CSR from edge pairs or Arrow RecordBatch - build_bidirectional_index: create both outgoing (CSR) and incoming (CSC) - Arrow serialization for persisting offset/neighbor tables as Lance datasets Closes lance-format#159 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Limit coverage to --lib tests (unit tests only) and cap parallel build jobs to 2 to prevent linker OOM (Bus error / signal 7) on the ubuntu-24.04 CI runner. The coverage-instrumented binary grew past the runner's memory limit with additional modules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a CSR (Compressed Sparse Row) adjacency index that enables O(1) neighbor lookup for graph traversal, replacing SQL join-based expansion with direct pointer-chasing. This is the foundation for wiring up the
LanceNativePlannerplaceholder with a real native execution path.Inspired by GraphAr's CSR-in-Parquet approach (Apache incubator), adapted for Lance's columnar format.
What's included
CsrIndex— in-memory CSR structure with:neighbors(vertex_id)— O(1) neighbor lookup via offset arraydegree(vertex_id)— O(1) out-degreebfs(start, max_hops)— k-hop BFS traversal returning vertices by distanceshortest_path(start, end)— BFS-based unweighted shortest pathto_record_batch()/neighbors_to_record_batch()— Arrow serialization for persisting as Lance datasetsCsrIndexBuilder— construct CSR from:add_edge(src, dst)callssrc_id/dst_idcolumns viaadd_edges_from_batch()build_bidirectional_index()— create both outgoing (CSR) and incoming (CSC) indices for undirected/reverse traversalWhy this matters
Currently lance-graph translates Cypher
MATCH (a)-[:KNOWS]->(b)into SQL joins via DataFusion. For multi-hop queries, this means:Next steps (not in this PR)
LanceNativePlannerto handleLogicalOperator::ExpandTest plan
cargo clippy -p lance-graph -- -D warningspasses cleanCloses #159