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 rename_node(&mut self, old_key: &str, new_key: &str) -> &mut Self

Queue a node-rename in this batch.

Validation (old exists, new not taken) runs at commit time.

Source

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

Queue an edge insert with endpoint auto-creation.

Any missing endpoint is created as a plain node {key, label: placeholder_label, no props} inside this batch frame. Rules fire and last-change is updated for each auto-created node.

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

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
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.