Skip to main content

RelTable

Struct RelTable 

Source
pub struct RelTable {
    pub table_id: u64,
    pub name: String,
    pub src_table_id: u64,
    pub dst_table_id: u64,
    pub columns: Vec<ColumnDefinition>,
    pub num_rows: u64,
    pub edges: Vec<(u64, u64)>,
    pub fwd_adj: HashMap<u64, Vec<(u64, usize)>>,
    pub rev_adj: HashMap<u64, Vec<(u64, usize)>>,
    pub csr_index: Option<CsrIndex>,
    pub properties: Vec<Vec<Value>>,
    pub persistence_dirty: bool,
}
Expand description

A relationship (edge) table with CSR (Compressed Sparse Row) adjacency storage.

Each edge connects a source node to a destination node and may carry a set of property values (one per column in columns).

§Storage layout

  • edges — flat edge list: edge_idx → (src_offset, dst_offset)
  • fwd_adj — forward index: src_offset → Vec<(dst_offset, edge_idx)>
  • rev_adj — reverse index: dst_offset → Vec<(src_offset, edge_idx)>
  • properties — column-major property storage: properties[col_idx][edge_idx]

Fields§

§table_id: u64§name: String§src_table_id: u64§dst_table_id: u64§columns: Vec<ColumnDefinition>§num_rows: u64§edges: Vec<(u64, u64)>

Flat edge list: edge_idx → (src_offset, dst_offset).

§fwd_adj: HashMap<u64, Vec<(u64, usize)>>

Forward CSR adjacency: src_offset → [(dst_offset, edge_idx), …].

§rev_adj: HashMap<u64, Vec<(u64, usize)>>

Reverse CSR adjacency: dst_offset → [(src_offset, edge_idx), …].

§csr_index: Option<CsrIndex>

Specialized CSR Index for fast graph traversals.

§properties: Vec<Vec<Value>>

Column-major property storage: properties[col_idx][edge_idx].

§persistence_dirty: bool

Set when an UPDATE/DELETE touches the table. The durable column mirror (see persistence.rs) performs a full rewrite when this flag is set.

Implementations§

Source§

impl RelTable

Source

pub fn new( table_id: u64, name: String, src_table_id: u64, dst_table_id: u64, columns: Vec<ColumnDefinition>, ) -> Self

Source

pub fn add_column(&mut self, column: ColumnDefinition)

Widen the rel table schema with a new property column (ALTER TABLE ADD). Existing edges get a NULL in the new property column (P53.37).

Source

pub fn insert_rel( &mut self, from: u64, to: u64, values: Vec<Value>, ) -> Result<(), StorageError>

Insert a relationship (edge) between two nodes with property values.

from and to are the node offsets of the source and destination nodes within their respective tables.

Returns an error if the number of values doesn’t match the number of property columns.

Source

pub fn insert_rels_batch( &mut self, rels: &[(u64, u64, Vec<Value>)], ) -> Result<u64, StorageError>

Batch insert multiple relations efficiently. Each tuple is (from_offset, to_offset, property_values).

Source

pub fn delete_edge(&mut self, edge_idx: usize) -> Result<(), StorageError>

Delete an edge by its index. Marks the edge as deleted by removing it from adjacency lists and setting its properties to Null.

Source

pub fn update_cell( &mut self, edge_idx: usize, col_idx: usize, value: Value, ) -> Result<(), StorageError>

Update a single cell (edge property) with a new value.

Source

pub fn edge_undo_bytes(&self, edge_idx: usize) -> Vec<u8>

Capture an edge (src, dst) plus all property values as serialized undo bytes: [src, dst, prop0..propN]. Used to record UndoType::Delete records so a rollback can restore a deleted edge (P52.18).

Source

pub fn edge_cell_undo_bytes(&self, edge_idx: usize, col_idx: usize) -> Vec<u8>

Capture a single edge property as serialized undo bytes. Used to record UndoType::Update records for SET rollback (P52.18).

Source

pub fn restore_deleted_edge( &mut self, edge_idx: usize, src: u64, dst: u64, props: Vec<Value>, ) -> Result<(), StorageError>

Restore a tombstoned edge (rollback of a DELETE edge). Re-adds the edge to the forward/reverse adjacency lists and restores its properties (P52.18).

Source

pub fn insert_row(&mut self, values: Vec<Value>) -> Result<u64, StorageError>

Insert a row of values (legacy alias that treats all columns as properties). Only the first two values are treated as (from, to) if the table has at least 2 columns; otherwise they are stored as pure properties.

Source

pub fn scan_adj_list(&self, src_offset: u64) -> &[(u64, usize)]

Scan the forward adjacency list for a given source node.

Returns a list of (dst_offset, edge_idx) pairs, or an empty vec if the node has no outgoing edges.

Source

pub fn scan_rev_adj_list(&self, dst_offset: u64) -> &[(u64, usize)]

Scan the reverse adjacency list for a given destination node.

Returns a list of (src_offset, edge_idx) pairs, or an empty vec if the node has no incoming edges.

Source

pub fn get_outgoing_edges(&self, src_offset: u64) -> Vec<(u64, Vec<Value>)>

Get all outgoing edges from a source node as (dst_offset, property_values).

Source

pub fn get_incoming_edges(&self, dst_offset: u64) -> Vec<(u64, Vec<Value>)>

Get all incoming edges to a destination node as (src_offset, property_values).

Source

pub fn get_edge_properties(&self, edge_idx: usize) -> Vec<Value>

Get the property values for a specific edge by index.

Source

pub fn get_column(&self, col_idx: usize) -> Option<&[Value]>

Get all values for a given property column (by index) as a slice.

Source

pub fn to_column_major_data(&self) -> Vec<Vec<Value>>

Reconstruct column-major data from properties for backward compatibility.

Trait Implementations§

Source§

impl Clone for RelTable

Source§

fn clone(&self) -> RelTable

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RelTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more