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: boolSet 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
impl RelTable
pub fn new( table_id: u64, name: String, src_table_id: u64, dst_table_id: u64, columns: Vec<ColumnDefinition>, ) -> Self
Sourcepub fn add_column(&mut self, column: ColumnDefinition)
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).
Sourcepub fn insert_rel(
&mut self,
from: u64,
to: u64,
values: Vec<Value>,
) -> Result<(), StorageError>
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.
Sourcepub fn insert_rels_batch(
&mut self,
rels: &[(u64, u64, Vec<Value>)],
) -> Result<u64, StorageError>
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).
Sourcepub fn delete_edge(&mut self, edge_idx: usize) -> Result<(), StorageError>
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.
Sourcepub fn update_cell(
&mut self,
edge_idx: usize,
col_idx: usize,
value: Value,
) -> Result<(), StorageError>
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.
Sourcepub fn edge_undo_bytes(&self, edge_idx: usize) -> Vec<u8> ⓘ
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).
Sourcepub fn edge_cell_undo_bytes(&self, edge_idx: usize, col_idx: usize) -> Vec<u8> ⓘ
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).
Sourcepub fn restore_deleted_edge(
&mut self,
edge_idx: usize,
src: u64,
dst: u64,
props: Vec<Value>,
) -> Result<(), StorageError>
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).
Sourcepub fn insert_row(&mut self, values: Vec<Value>) -> Result<u64, StorageError>
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.
Sourcepub fn scan_adj_list(&self, src_offset: u64) -> &[(u64, usize)]
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.
Sourcepub fn scan_rev_adj_list(&self, dst_offset: u64) -> &[(u64, usize)]
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.
Sourcepub fn get_outgoing_edges(&self, src_offset: u64) -> Vec<(u64, Vec<Value>)>
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).
Sourcepub fn get_incoming_edges(&self, dst_offset: u64) -> Vec<(u64, Vec<Value>)>
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).
Sourcepub fn get_edge_properties(&self, edge_idx: usize) -> Vec<Value>
pub fn get_edge_properties(&self, edge_idx: usize) -> Vec<Value>
Get the property values for a specific edge by index.
Sourcepub fn get_column(&self, col_idx: usize) -> Option<&[Value]>
pub fn get_column(&self, col_idx: usize) -> Option<&[Value]>
Get all values for a given property column (by index) as a slice.
Sourcepub fn to_column_major_data(&self) -> Vec<Vec<Value>>
pub fn to_column_major_data(&self) -> Vec<Vec<Value>>
Reconstruct column-major data from properties for backward compatibility.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RelTable
impl RefUnwindSafe for RelTable
impl Send for RelTable
impl Sync for RelTable
impl Unpin for RelTable
impl UnsafeUnpin for RelTable
impl UnwindSafe for RelTable
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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