Skip to main content

AdjacencyHelpers

Struct AdjacencyHelpers 

Source
pub struct AdjacencyHelpers;
Expand description

Helper functions for adjacency operations

Implementations§

Source§

impl AdjacencyHelpers

Source

pub fn get_outgoing_neighbors( graph_file: &mut GraphFile, node_id: NativeNodeId, ) -> NativeResult<Vec<NativeNodeId>>

Get outgoing neighbors for a node

Source

pub fn get_incoming_neighbors( graph_file: &mut GraphFile, node_id: NativeNodeId, ) -> NativeResult<Vec<NativeNodeId>>

Get incoming neighbors for a node

Source

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

Source

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

Source

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)

Source

pub fn outgoing_degree( graph_file: &mut GraphFile, node_id: NativeNodeId, ) -> NativeResult<u32>

Get degree of node (number of outgoing edges)

Source

pub fn incoming_degree( graph_file: &mut GraphFile, node_id: NativeNodeId, ) -> NativeResult<u32>

Get degree of node (number of incoming edges)

Source

pub fn total_degree( graph_file: &mut GraphFile, node_id: NativeNodeId, ) -> NativeResult<u32>

Get total degree of node (incoming + outgoing)

Source

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:

  1. Read base neighbors from GraphFile (always visible - checkpointed data)
  2. Read WAL records for this node
  3. Filter WAL records by commit_lsn <= snapshot_id.as_lsn()
  4. 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.

Source

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.

Source

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)
}
Source

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

Source

pub fn validate_all_adjacency(graph_file: &mut GraphFile) -> NativeResult<()>

Validate adjacency consistency across all nodes

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V