pub struct AdjacencyHelpers;Expand description
Helper functions for adjacency operations
Implementations§
Source§impl AdjacencyHelpers
impl AdjacencyHelpers
Sourcepub fn get_outgoing_neighbors(
graph_file: &mut GraphFile,
node_id: NativeNodeId,
) -> NativeResult<Vec<NativeNodeId>>
pub fn get_outgoing_neighbors( graph_file: &mut GraphFile, node_id: NativeNodeId, ) -> NativeResult<Vec<NativeNodeId>>
Get outgoing neighbors for a node
Sourcepub fn get_incoming_neighbors(
graph_file: &mut GraphFile,
node_id: NativeNodeId,
) -> NativeResult<Vec<NativeNodeId>>
pub fn get_incoming_neighbors( graph_file: &mut GraphFile, node_id: NativeNodeId, ) -> NativeResult<Vec<NativeNodeId>>
Get incoming neighbors for a node
Sourcepub fn get_outgoing_neighbors_filtered(
graph_file: &mut GraphFile,
node_id: NativeNodeId,
edge_types: &[&str],
) -> NativeResult<Vec<NativeNodeId>>
pub fn get_outgoing_neighbors_filtered( graph_file: &mut GraphFile, node_id: NativeNodeId, edge_types: &[&str], ) -> NativeResult<Vec<NativeNodeId>>
Get outgoing neighbors filtered by edge type
Sourcepub fn get_incoming_neighbors_filtered(
graph_file: &mut GraphFile,
node_id: NativeNodeId,
edge_types: &[&str],
) -> NativeResult<Vec<NativeNodeId>>
pub fn get_incoming_neighbors_filtered( graph_file: &mut GraphFile, node_id: NativeNodeId, edge_types: &[&str], ) -> NativeResult<Vec<NativeNodeId>>
Get incoming neighbors filtered by edge type
Sourcepub fn has_direct_edge(
graph_file: &mut GraphFile,
source_id: NativeNodeId,
target_id: NativeNodeId,
) -> NativeResult<bool>
pub fn has_direct_edge( graph_file: &mut GraphFile, source_id: NativeNodeId, target_id: NativeNodeId, ) -> NativeResult<bool>
Check if there’s a path from source to target (direct edge)
Sourcepub fn outgoing_degree(
graph_file: &mut GraphFile,
node_id: NativeNodeId,
) -> NativeResult<u32>
pub fn outgoing_degree( graph_file: &mut GraphFile, node_id: NativeNodeId, ) -> NativeResult<u32>
Get degree of node (number of outgoing edges)
Sourcepub fn incoming_degree(
graph_file: &mut GraphFile,
node_id: NativeNodeId,
) -> NativeResult<u32>
pub fn incoming_degree( graph_file: &mut GraphFile, node_id: NativeNodeId, ) -> NativeResult<u32>
Get degree of node (number of incoming edges)
Sourcepub fn total_degree(
graph_file: &mut GraphFile,
node_id: NativeNodeId,
) -> NativeResult<u32>
pub fn total_degree( graph_file: &mut GraphFile, node_id: NativeNodeId, ) -> NativeResult<u32>
Get total degree of node (incoming + outgoing)
Sourcepub fn get_outgoing_neighbors_at_snapshot(
graph_file: &mut GraphFile,
node_id: NativeNodeId,
snapshot_id: SnapshotId,
) -> NativeResult<Vec<NativeNodeId>>
pub fn get_outgoing_neighbors_at_snapshot( graph_file: &mut GraphFile, node_id: NativeNodeId, snapshot_id: SnapshotId, ) -> NativeResult<Vec<NativeNodeId>>
Get outgoing neighbors at a specific snapshot
This is the snapshot-aware version of get_outgoing_neighbors.
For now, it delegates to the non-snapshot version since WAL filtering
requires full WAL reader integration (deferred to future phases).
§Architecture Note
Full implementation requires:
- Read base neighbors from GraphFile (always visible - checkpointed data)
- Read WAL records for this node
- Filter WAL records by commit_lsn <= snapshot_id.as_lsn()
- Apply visible WAL records to base neighbors
Current implementation returns base data only, which is correct for checkpointed data but doesn’t include committed-but-not-checkpointed WAL records.
Sourcepub fn get_incoming_neighbors_at_snapshot(
graph_file: &mut GraphFile,
node_id: NativeNodeId,
snapshot_id: SnapshotId,
) -> NativeResult<Vec<NativeNodeId>>
pub fn get_incoming_neighbors_at_snapshot( graph_file: &mut GraphFile, node_id: NativeNodeId, snapshot_id: SnapshotId, ) -> NativeResult<Vec<NativeNodeId>>
Get incoming neighbors at a specific snapshot
See get_outgoing_neighbors_at_snapshot for architecture notes.
Sourcepub fn get_neighbors_at_snapshot(
graph_file: &mut GraphFile,
node_id: NativeNodeId,
snapshot_id: SnapshotId,
direction: Direction,
) -> NativeResult<Vec<NativeNodeId>>
pub fn get_neighbors_at_snapshot( graph_file: &mut GraphFile, node_id: NativeNodeId, snapshot_id: SnapshotId, direction: Direction, ) -> NativeResult<Vec<NativeNodeId>>
Get neighbors with snapshot filtering via commit_lsn
This is the main entry point for snapshot-aware neighbor retrieval. It filters WAL records to only show data from transactions with commit_lsn <= snapshot_id.
§Future Implementation
pub fn get_neighbors_at_snapshot(
graph_file: &GraphFile,
wal_reader: &V2WALReader,
snapshot_id: SnapshotId,
node_id: NativeNodeId,
) -> Result<Vec<NativeNodeId>, NativeBackendError> {
// 1. Read base data (always visible - from checkpoint)
let mut neighbors = Self::read_base_neighbors(graph_file, node_id)?;
// 2. Apply only WAL records from committed transactions
for wal_record in wal_reader.iter_node_records(node_id)? {
// Get transaction for this record (by contiguity, tracked in tx_index)
if let Some(tx_range) = wal_reader.tx_index().get_tx_range_for_lsn(wal_record.lsn) {
// Check if transaction was committed at or before snapshot
if let Some(commit_lsn) = tx_range.commit_lsn {
if commit_lsn <= snapshot_id.as_lsn() {
neighbors.apply_wal_record(wal_record)?;
}
}
}
}
Ok(neighbors)
}Sourcepub fn validate_node_adjacency(
graph_file: &mut GraphFile,
node_id: NativeNodeId,
) -> NativeResult<()>
pub fn validate_node_adjacency( graph_file: &mut GraphFile, node_id: NativeNodeId, ) -> NativeResult<()>
Validate adjacency consistency for a single node with strict real adjacency checks
Sourcepub fn validate_all_adjacency(graph_file: &mut GraphFile) -> NativeResult<()>
pub fn validate_all_adjacency(graph_file: &mut GraphFile) -> NativeResult<()>
Validate adjacency consistency across all nodes
Auto Trait Implementations§
impl Freeze for AdjacencyHelpers
impl RefUnwindSafe for AdjacencyHelpers
impl Send for AdjacencyHelpers
impl Sync for AdjacencyHelpers
impl Unpin for AdjacencyHelpers
impl UnwindSafe for AdjacencyHelpers
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more