Skip to main content

Mutator

Struct Mutator 

Source
pub struct Mutator<'tx, 'g> { /* private fields */ }
Expand description

Borrowed mutation builder for one write transaction.

Implementations§

Source§

impl<'tx, 'g> Mutator<'tx, 'g>

Source

pub fn create_node_type( &mut self, name: DbString, key_labels: LabelSet, properties: Vec<PropertyTypeDef>, validation_mode: ValidationMode, ) -> GraphResult<()>

Add a node type to the transaction-local closed graph type.

§Errors

Returns GraphError::Inconsistent when the graph is open, the type already exists, or the resulting graph type is structurally invalid.

Source

pub fn create_edge_type( &mut self, name: DbString, label: DbString, source_node_type: EdgeEndpointDef, target_node_type: EdgeEndpointDef, properties: Vec<PropertyTypeDef>, validation_mode: ValidationMode, ) -> GraphResult<()>

Add an edge type to the transaction-local closed graph type.

§Errors

Returns GraphError::Inconsistent when the graph is open, the type already exists, an endpoint index is invalid, or the resulting graph type is structurally invalid.

Source

pub fn drop_node_type( &mut self, name: DbString, behavior: DropBehavior, ) -> GraphResult<()>

Drop a node type from the transaction-local closed graph type.

behavior selects the surviving-instance / inbound-dependency policy (deletion-reclamation audit Item 3, Seam B):

  • DropBehavior::Restrict (the default) rejects the drop with GraphError::Inconsistent when any instance still carries name as its key label, or when an edge type still references the node type (dangling-endpoint guard). Nothing is removed — no Change is recorded and the bound graph type is left intact (no partial state).
  • DropBehavior::Cascade (IM_DROP_CASCADE) truncates every instance first via Mutator::truncate_node_type (which also removes incident edges, so no dangling endpoints remain), then drops the type. Both the truncate change(s) and the SchemaChange::NodeTypeDropped land in the same transaction, so commit and WAL replay are atomic.
§Errors

Returns GraphError::Inconsistent when the graph is open, the type does not exist, Restrict finds surviving instances or an inbound edge dependency, or any edge endpoint would require positional endpoint reindexing.

Source

pub fn drop_edge_type( &mut self, name: DbString, behavior: DropBehavior, ) -> GraphResult<()>

Drop an edge type from the transaction-local closed graph type.

behavior selects the surviving-instance policy (deletion-reclamation audit Item 3, Seam B). Edge types have no inbound type dependency, so only the instance check applies:

§Errors

Returns GraphError::Inconsistent when the graph is open, the type does not exist, Restrict finds surviving instances, or the resulting graph type is structurally invalid.

Source§

impl<'tx, 'g> Mutator<'tx, 'g>

Source

pub fn create_composite_property_index_named( &mut self, label: DbString, properties: SmallVec<[DbString; 4]>, kinds: SmallVec<[TypedIndexKind; 4]>, name: Option<DbString>, ) -> GraphResult<()>

Register a durable node composite-property index with optional catalog name.

§Errors

Returns GraphError::CompositePropertyIndexAlreadyExists if the canonical property set already exists.

Source

pub fn drop_composite_property_index( &mut self, label: DbString, properties: SmallVec<[DbString; 4]>, ) -> GraphResult<()>

Drop a durable node composite-property index from the active write transaction.

The operation is idempotent. Dropping an absent index succeeds and emits no WAL change.

Source§

impl<'tx, 'g> Mutator<'tx, 'g>

Source

pub fn delete_node(&mut self, id: NodeId) -> GraphResult<()>

Delete an alive node and cascade delete incident edges.

Source

pub fn delete_edge(&mut self, id: EdgeId) -> GraphResult<()>

Delete an alive edge.

Source

pub fn truncate_node_type(&mut self, label: DbString) -> GraphResult<()>

Remove every node carrying label and all of their incident edges in one declarative truncate.

Observationally identical to MATCH (n:L) DETACH DELETE n: every matched node and every incident edge (of any edge type, derived from both adjacency directions) is removed via the same change-free in-memory path delete_node/delete_edge_inner use, so the resulting graph state is byte-identical. The difference is the changeset: exactly one declarative Change::NodesOfTypeTruncated is recorded regardless of the number of rows removed (O(1) WAL write, deletion-reclamation audit Item 11), while the per-row NodeDeleted/EdgeDeleted tombstones are staged for provider/subscriber fan-out so derived state (e.g. extension providers) is reclaimed without leaks. An absent label is a clean no-op (no change is recorded), matching DETACH DELETE of zero matches; a second truncate of the same label is therefore idempotent.

All logic lives in the mutator (the single write funnel, hard rule 11) so future DROP NODE TYPE CASCADE and DROP GRAPH factory-reset paths can reuse it without an N+1 change storm.

Source

pub fn truncate_edge_type(&mut self, label: DbString) -> GraphResult<()>

Remove every edge carrying label in one declarative truncate.

Observationally identical to MATCH ()-[e:L]->() DELETE e: each matched edge is removed via the same change-free path delete_edge uses, leaving the graph dangling-free. Records exactly one declarative Change::EdgesOfTypeTruncated (O(1) WAL) and stages per-row EdgeDeleted tombstones for fan-out. Absent label is a clean idempotent no-op.

Source§

impl<'tx, 'g> Mutator<'tx, 'g>

Source

pub fn delete_elements( &mut self, nodes: BTreeSet<NodeId>, edges: BTreeSet<EdgeId>, ) -> GraphResult<()>

Delete a set of node and edge references.

Nodes are deleted first through Self::delete_node, so incident edges keep the same cascade behavior and change ordering as a direct node delete. Explicit edges already removed by a node cascade are skipped during the edge pass. IDs that are mapped but already invalidated are clean no-ops, matching set-oriented query deletion where duplicate rows may reference the same graph element more than once. IDs that were never allocated still return the same not-found errors as single-element delete calls. The full set is validated before the first row is removed, so a mixed set cannot partially mutate the transaction before surfacing a missing-id error.

Source§

impl<'tx, 'g> Mutator<'tx, 'g>

Source

pub fn factory_reset(&mut self) -> GraphResult<()>

Factory-reset the entire graph: wipe every node and edge and reset the schema to open, recording exactly one declarative Change::GraphReset (deletion-reclamation audit Item 10, BRIEF-152).

This is the DROP GRAPH primitive. Under D1 single-graph it targets the one bound graph. Behaviour and invariants:

  • Wipes ALL rows, including untyped ones. Live rows are enumerated from the two alive roaring::RoaringBitmaps (crate::SeleneGraph::live_nodes / crate::SeleneGraph::live_edges), never per label — so nodes/edges whose labels are not declared types (legal in an open GG01 graph) are removed too. A per-type truncate would silently miss them.
  • Resets the schema to open. meta.bound_type is set to None, making a previously closed (GG02) graph open (GG01) again. There are no standalone type defs outside bound_type, so clearing it is the complete schema reset. As a side effect, the commit-time closed-graph validation loop (write_txn) is skipped entirely once bound_type is None, which is correct — nothing is left to validate.
  • O(1) WAL. Exactly one Change::GraphReset is pushed regardless of the number of rows removed. The per-row NodeDeleted/EdgeDeleted tombstones are staged into the fan-out buffer (truncate_expansions) only, never into the persisted changeset, so derived state (e.g. the label/property indexes) is reclaimed without leaks while the WAL stays constant-size.
  • Idempotent. On an already-empty + open graph the row enumeration is empty and bound_type is already None; a GraphReset is still pushed with an empty staged expansion (which the fan-out expander drops), so a second DROP GRAPH is a clean observable no-op, never an error.

The MANIFEST epoch and WAL archive lineage are untouched: this is one committed WAL entry on top of the existing snapshot, not a file-level wipe.

§Errors

Returns a crate::GraphError only if the change-free removal cores hit a structural inconsistency (e.g. a missing edge row for a live index entry) — the same error surface the truncate path exposes.

Source§

impl<'tx, 'g> Mutator<'tx, 'g>

Source

pub fn create_property_index( &mut self, label: DbString, property: DbString, kind: TypedIndexKind, ) -> GraphResult<()>

Register a durable node property index in the active write transaction.

§Errors

Returns GraphError::PropertyIndexAlreadyExists if the pair already exists, or GraphError::IndexValueRejected if any existing non-null value for (label, property) cannot be admitted to kind.

Source

pub fn create_property_index_named( &mut self, label: DbString, property: DbString, kind: TypedIndexKind, name: Option<DbString>, ) -> GraphResult<()>

Register a durable node property index with optional catalog name.

Source

pub fn create_edge_property_index( &mut self, label: DbString, property: DbString, kind: TypedIndexKind, ) -> GraphResult<()>

Register a durable edge property index in the active write transaction.

§Errors

Returns GraphError::PropertyIndexAlreadyExists if the pair already exists, or GraphError::IndexValueRejected if any existing non-null edge value for (label, property) cannot be admitted to kind.

Source

pub fn create_edge_property_index_named( &mut self, label: DbString, property: DbString, kind: TypedIndexKind, name: Option<DbString>, ) -> GraphResult<()>

Register a durable edge property index with optional catalog name.

Source

pub fn drop_edge_property_index( &mut self, label: DbString, property: DbString, ) -> GraphResult<()>

Drop a durable edge property index from the active write transaction.

The operation is idempotent. Dropping an absent index succeeds and emits no WAL change.

Source

pub fn drop_property_index( &mut self, label: DbString, property: DbString, ) -> GraphResult<()>

Drop a durable node property index from the active write transaction.

The operation is idempotent. Dropping an absent index succeeds and emits no WAL change.

Source§

impl<'tx, 'g> Mutator<'tx, 'g>

Source

pub fn remove_node_property( &mut self, id: NodeId, property: DbString, ) -> GraphResult<()>

Remove a property from an alive node and emit Change::NodePropertyRemoved.

The mutation is a no-op when property is absent.

Source

pub fn remove_edge_property( &mut self, id: EdgeId, property: DbString, ) -> GraphResult<()>

Remove a property from an alive edge and emit Change::EdgePropertyRemoved.

The mutation is a no-op when property is absent.

Source

pub fn remove_node_label( &mut self, id: NodeId, label: DbString, ) -> GraphResult<()>

Remove a label from an alive node and emit Change::NodeLabelRemoved.

The mutation is a no-op when label is absent.

Source§

impl<'tx, 'g> Mutator<'tx, 'g>

Source

pub fn create_text_index( &mut self, label: DbString, property: DbString, ) -> GraphResult<()>

Register a durable node text index in the active write transaction.

§Errors

Returns GraphError::TextIndexAlreadyExists if the pair already exists, or GraphError::Inconsistent if index construction observes corrupt graph columns.

Source

pub fn create_text_index_named( &mut self, label: DbString, property: DbString, name: Option<DbString>, ) -> GraphResult<()>

Register a durable node text index with optional catalog name.

Source

pub fn drop_text_index( &mut self, label: DbString, property: DbString, ) -> GraphResult<()>

Drop a durable node text index from the active write transaction.

The operation is idempotent. Dropping an absent index succeeds and emits no WAL change.

Source§

impl<'tx, 'g> Mutator<'tx, 'g>

Source

pub fn create_vector_index( &mut self, label: DbString, property: DbString, kind: VectorIndexKind, dimension: u32, ) -> GraphResult<()>

Register a durable node vector index in the active write transaction.

§Errors

Returns GraphError::VectorIndexAlreadyExists if the pair already exists, GraphError::VectorIndexInvalidDimension when dimension is zero, or GraphError::VectorIndexValueRejected if an existing non-null value for (label, property) is not a vector with dimension.

Source

pub fn create_vector_index_named( &mut self, label: DbString, property: DbString, kind: VectorIndexKind, dimension: u32, name: Option<DbString>, ) -> GraphResult<()>

Register a durable node vector index with optional catalog name.

Source

pub fn create_vector_index_named_with_config( &mut self, label: DbString, property: DbString, kind: VectorIndexKind, dimension: u32, name: Option<DbString>, hnsw_config: Option<HnswIndexConfig>, ) -> GraphResult<()>

Register a durable node vector index with optional HNSW construction config.

Source

pub fn create_vector_index_named_with_configs( &mut self, label: DbString, property: DbString, kind: VectorIndexKind, dimension: u32, name: Option<DbString>, config: VectorIndexConfig, ) -> GraphResult<()>

Register a durable node vector index with optional ANN construction config.

Source

pub fn drop_vector_index( &mut self, label: DbString, property: DbString, ) -> GraphResult<()>

Drop a durable node vector index from the active write transaction.

The operation is idempotent. Dropping an absent index succeeds and emits no WAL change.

Source§

impl<'tx, 'g> Mutator<'tx, 'g>

Source

pub fn create_node( &mut self, labels: LabelSet, props: PropertyMap, ) -> GraphResult<NodeId>

Create a node, emit Change::NodeCreated, and return its ID.

§Errors

Returns GraphError::RowSpaceExhausted when the dense row store fills the v1 row-index range (max 2^32 rows).

Source

pub fn create_edge( &mut self, label: DbString, source: NodeId, target: NodeId, props: PropertyMap, ) -> GraphResult<EdgeId>

Create an edge between two alive nodes.

Source

pub fn update_node( &mut self, id: NodeId, labels_diff: LabelDiff, props_diff: PropertyDiff, ) -> GraphResult<()>

Update an alive node and emit Change::NodeUpdated.

Source

pub fn update_edge( &mut self, id: EdgeId, props_diff: PropertyDiff, ) -> GraphResult<()>

Update an alive edge and emit Change::EdgeUpdated.

Edge labels are immutable, so property updates do not touch idx_edge_label.

Source

pub fn schema_change(&mut self, graph: GraphId, change: SchemaChange)

Append a raw SchemaChange WAL payload through the write funnel.

This is a pass-through accumulator: catalog graph mutation and closed-graph validation are handled by higher-level validation layers (the typed catalog DDL methods on this Mutator — e.g. create_node_type — call those layers and then funnel here).

Why: this is the single, canonical funnel entry for a SchemaChanged change record (hard rule 11 — every mutation routes through the one Mutator). It is intentionally retained as a pub funnel surface even though no GQL caller reaches it directly today: the catalog DDL methods are the production producers, and keeping the low-level entry public means any future schema-event producer routes through the same funnel rather than re-implementing the write path. Tests and benches drive it directly to exercise the raw funnel without the DDL validation layer on top.

Source

pub fn index_provider_by_tag( &self, tag: ProviderTag, ) -> Option<Arc<dyn IndexProvider>>

Look up a registered index provider through the held write transaction.

Source

pub fn read(&self) -> &SeleneGraph

Borrow the transaction-local working graph.

Auto Trait Implementations§

§

impl<'tx, 'g> !RefUnwindSafe for Mutator<'tx, 'g>

§

impl<'tx, 'g> !Send for Mutator<'tx, 'g>

§

impl<'tx, 'g> !UnwindSafe for Mutator<'tx, 'g>

§

impl<'tx, 'g> Freeze for Mutator<'tx, 'g>

§

impl<'tx, 'g> Sync for Mutator<'tx, 'g>

§

impl<'tx, 'g> Unpin for Mutator<'tx, 'g>

§

impl<'tx, 'g> UnsafeUnpin for Mutator<'tx, 'g>

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> 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> 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> 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> 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 = 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<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