pub struct Mutator<'tx, 'g> { /* private fields */ }Expand description
Borrowed mutation builder for one write transaction.
Implementations§
Source§impl<'tx, 'g> Mutator<'tx, 'g>
impl<'tx, 'g> Mutator<'tx, 'g>
Sourcepub fn create_node_type(
&mut self,
name: DbString,
key_labels: LabelSet,
properties: Vec<PropertyTypeDef>,
validation_mode: ValidationMode,
) -> GraphResult<()>
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.
Sourcepub 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<()>
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.
Sourcepub fn drop_node_type(
&mut self,
name: DbString,
behavior: DropBehavior,
) -> GraphResult<()>
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 withGraphError::Inconsistentwhen any instance still carriesnameas its key label, or when an edge type still references the node type (dangling-endpoint guard). Nothing is removed — noChangeis recorded and the bound graph type is left intact (no partial state).DropBehavior::Cascade(IM_DROP_CASCADE) truncates every instance first viaMutator::truncate_node_type(which also removes incident edges, so no dangling endpoints remain), then drops the type. Both the truncate change(s) and theSchemaChange::NodeTypeDroppedland 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.
Sourcepub fn drop_edge_type(
&mut self,
name: DbString,
behavior: DropBehavior,
) -> GraphResult<()>
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:
DropBehavior::Restrict(the default) rejects withGraphError::Inconsistentwhen any edge still carriesname; nothing is removed and noChangeis recorded.DropBehavior::Cascade(IM_DROP_CASCADE) truncates every edge of the type first viaMutator::truncate_edge_type, then drops the type, atomically in one transaction.
§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>
impl<'tx, 'g> Mutator<'tx, 'g>
Sourcepub fn create_composite_property_index_named(
&mut self,
label: DbString,
properties: SmallVec<[DbString; 4]>,
kinds: SmallVec<[TypedIndexKind; 4]>,
name: Option<DbString>,
) -> GraphResult<()>
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.
Sourcepub fn drop_composite_property_index(
&mut self,
label: DbString,
properties: SmallVec<[DbString; 4]>,
) -> GraphResult<()>
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>
impl<'tx, 'g> Mutator<'tx, 'g>
Sourcepub fn delete_node(&mut self, id: NodeId) -> GraphResult<()>
pub fn delete_node(&mut self, id: NodeId) -> GraphResult<()>
Delete an alive node and cascade delete incident edges.
Sourcepub fn delete_edge(&mut self, id: EdgeId) -> GraphResult<()>
pub fn delete_edge(&mut self, id: EdgeId) -> GraphResult<()>
Delete an alive edge.
Sourcepub fn truncate_node_type(&mut self, label: DbString) -> GraphResult<()>
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.
Sourcepub fn truncate_edge_type(&mut self, label: DbString) -> GraphResult<()>
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>
impl<'tx, 'g> Mutator<'tx, 'g>
Sourcepub fn delete_elements(
&mut self,
nodes: BTreeSet<NodeId>,
edges: BTreeSet<EdgeId>,
) -> GraphResult<()>
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>
impl<'tx, 'g> Mutator<'tx, 'g>
Sourcepub fn factory_reset(&mut self) -> GraphResult<()>
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_typeis set toNone, making a previously closed (GG02) graph open (GG01) again. There are no standalone type defs outsidebound_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 oncebound_typeisNone, which is correct — nothing is left to validate. - O(1) WAL. Exactly one
Change::GraphResetis pushed regardless of the number of rows removed. The per-rowNodeDeleted/EdgeDeletedtombstones 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_typeis alreadyNone; aGraphResetis still pushed with an empty staged expansion (which the fan-out expander drops), so a secondDROP GRAPHis 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>
impl<'tx, 'g> Mutator<'tx, 'g>
Sourcepub fn create_property_index(
&mut self,
label: DbString,
property: DbString,
kind: TypedIndexKind,
) -> GraphResult<()>
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.
Sourcepub fn create_property_index_named(
&mut self,
label: DbString,
property: DbString,
kind: TypedIndexKind,
name: Option<DbString>,
) -> GraphResult<()>
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.
Sourcepub fn create_edge_property_index(
&mut self,
label: DbString,
property: DbString,
kind: TypedIndexKind,
) -> GraphResult<()>
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.
Sourcepub fn create_edge_property_index_named(
&mut self,
label: DbString,
property: DbString,
kind: TypedIndexKind,
name: Option<DbString>,
) -> GraphResult<()>
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.
Sourcepub fn drop_edge_property_index(
&mut self,
label: DbString,
property: DbString,
) -> GraphResult<()>
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.
Sourcepub fn drop_property_index(
&mut self,
label: DbString,
property: DbString,
) -> GraphResult<()>
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>
impl<'tx, 'g> Mutator<'tx, 'g>
Sourcepub fn remove_node_property(
&mut self,
id: NodeId,
property: DbString,
) -> GraphResult<()>
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.
Sourcepub fn remove_edge_property(
&mut self,
id: EdgeId,
property: DbString,
) -> GraphResult<()>
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.
Sourcepub fn remove_node_label(
&mut self,
id: NodeId,
label: DbString,
) -> GraphResult<()>
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>
impl<'tx, 'g> Mutator<'tx, 'g>
Sourcepub fn create_text_index(
&mut self,
label: DbString,
property: DbString,
) -> GraphResult<()>
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.
Sourcepub fn create_text_index_named(
&mut self,
label: DbString,
property: DbString,
name: Option<DbString>,
) -> GraphResult<()>
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.
Sourcepub fn drop_text_index(
&mut self,
label: DbString,
property: DbString,
) -> GraphResult<()>
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>
impl<'tx, 'g> Mutator<'tx, 'g>
Sourcepub fn create_vector_index(
&mut self,
label: DbString,
property: DbString,
kind: VectorIndexKind,
dimension: u32,
) -> GraphResult<()>
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.
Sourcepub fn create_vector_index_named(
&mut self,
label: DbString,
property: DbString,
kind: VectorIndexKind,
dimension: u32,
name: Option<DbString>,
) -> GraphResult<()>
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.
Sourcepub 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<()>
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.
Sourcepub fn create_vector_index_named_with_configs(
&mut self,
label: DbString,
property: DbString,
kind: VectorIndexKind,
dimension: u32,
name: Option<DbString>,
config: VectorIndexConfig,
) -> GraphResult<()>
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.
Sourcepub fn drop_vector_index(
&mut self,
label: DbString,
property: DbString,
) -> GraphResult<()>
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>
impl<'tx, 'g> Mutator<'tx, 'g>
Sourcepub fn create_node(
&mut self,
labels: LabelSet,
props: PropertyMap,
) -> GraphResult<NodeId>
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).
Sourcepub fn create_edge(
&mut self,
label: DbString,
source: NodeId,
target: NodeId,
props: PropertyMap,
) -> GraphResult<EdgeId>
pub fn create_edge( &mut self, label: DbString, source: NodeId, target: NodeId, props: PropertyMap, ) -> GraphResult<EdgeId>
Create an edge between two alive nodes.
Sourcepub fn update_node(
&mut self,
id: NodeId,
labels_diff: LabelDiff,
props_diff: PropertyDiff,
) -> GraphResult<()>
pub fn update_node( &mut self, id: NodeId, labels_diff: LabelDiff, props_diff: PropertyDiff, ) -> GraphResult<()>
Update an alive node and emit Change::NodeUpdated.
Sourcepub fn update_edge(
&mut self,
id: EdgeId,
props_diff: PropertyDiff,
) -> GraphResult<()>
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.
Sourcepub fn schema_change(&mut self, graph: GraphId, change: SchemaChange)
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.
Sourcepub fn index_provider_by_tag(
&self,
tag: ProviderTag,
) -> Option<Arc<dyn IndexProvider>>
pub fn index_provider_by_tag( &self, tag: ProviderTag, ) -> Option<Arc<dyn IndexProvider>>
Look up a registered index provider through the held write transaction.
Sourcepub fn read(&self) -> &SeleneGraph
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> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.