Skip to main content

BatchBuilder

Struct BatchBuilder 

Source
pub struct BatchBuilder<'a, F: Fs> { /* private fields */ }
Expand description

Collects mutations and commits them as one WAL Batch frame.

Holds &mut GraphDb for its lifetime. Queue with the same method names as GraphDb; call commit to validate, log, and apply. See GraphDb::batch for validation and atomicity rules.

Implementations§

Source§

impl<'a, F: Fs> BatchBuilder<'a, F>

Source

pub fn insert_node( &mut self, label: &str, key: &str, props: Vec<(String, Value)>, ) -> &mut Self

Source

pub fn insert_edge( &mut self, edge_type: &str, src_key: &str, dst_key: &str, ) -> &mut Self

Source

pub fn set_prop(&mut self, key: &str, field: &str, value: Value) -> &mut Self

Source

pub fn remove_prop(&mut self, key: &str, field: &str) -> &mut Self

Source

pub fn delete_edge( &mut self, edge_type: &str, src_key: &str, dst_key: &str, ) -> &mut Self

Source

pub fn delete_node(&mut self, key: &str) -> &mut Self

Source

pub fn create_rule(&mut self, def: RuleDef) -> &mut Self

Source

pub fn delete_rule(&mut self, name: &str) -> &mut Self

Source

pub fn commit(&mut self) -> Result<(usize, usize)>

Validate every queued op, then log one Batch frame and apply. Empty / all-noop batches return Ok(()) without writing the WAL. A second commit() after a successful one is an empty-batch no-op (queued ops were taken). Takes &mut self so it chains after the queue methods (b.insert_node(..).commit()) and also works as let mut b = db.batch(); b.insert_node(..); b.commit().

Rule-window limitation: batch validation cannot see edges that a rule created earlier in the same batch will derive at apply time, so a delete_edge / insert_edge in that window is silently no-oped where sequential calls would return Err(RuleOwned). State integrity is unaffected (idempotent apply, provenance intact). Create rules in their own batch, or sequentially, when later ops may touch derived edges. Validate every queued op and commit atomically.

Returns (nodes_inserted, edges_inserted) — the counts of node and edge WAL records actually written (duplicate edges are silent no-ops and are NOT counted). Both are 0 when the batch is empty or all-noop.

Auto Trait Implementations§

§

impl<'a, F> !RefUnwindSafe for BatchBuilder<'a, F>

§

impl<'a, F> !UnwindSafe for BatchBuilder<'a, F>

§

impl<'a, F> Freeze for BatchBuilder<'a, F>
where &'a mut GraphDb<F>: Freeze,

§

impl<'a, F> Send for BatchBuilder<'a, F>
where &'a mut GraphDb<F>: Send,

§

impl<'a, F> Sync for BatchBuilder<'a, F>
where &'a mut GraphDb<F>: Sync,

§

impl<'a, F> Unpin for BatchBuilder<'a, F>
where &'a mut GraphDb<F>: Unpin,

§

impl<'a, F> UnsafeUnpin for BatchBuilder<'a, F>
where &'a mut GraphDb<F>: UnsafeUnpin,

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, 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, <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.