pub struct GraphLabelRegistry {
pub labels: BTreeMap<String, u32>,
pub kinds: BTreeMap<String, LabelKind>,
pub sequences: BTreeMap<u32, u64>,
pub dropped_label_ids: BTreeSet<u32>,
pub next_label_id: u32,
}Expand description
Per-graph AGE label registry: label name -> label id plus the per-label id sequences. Serializable so engines can persist it in catalog metadata and restore deterministic id allocation.
Fields§
§labels: BTreeMap<String, u32>Label name -> AGE label id. Vertex and edge labels share the namespace-wide counter; the reserved names for ids 1 / 2 are not stored here (empty labels map onto them implicitly).
kinds: BTreeMap<String, LabelKind>Label name -> vertex or edge kind. Registries persisted before kinds were recorded fill this map from the stored entities.
sequences: BTreeMap<u32, u64>Label id -> last allocated per-label sequence value.
dropped_label_ids: BTreeSet<u32>AGE label ids whose relations were removed through drop_label.
Tombstones are persisted because edge rows can outlive the vertex
label relations that owned their endpoints. Registries written before
this field existed deserialize as an empty set.
next_label_id: u32Next label id handed to a previously unseen label.
Implementations§
Source§impl GraphLabelRegistry
impl GraphLabelRegistry
Sourcepub fn contains_label(&self, label: &str) -> bool
pub fn contains_label(&self, label: &str) -> bool
Whether label names a registered user label or a reserved
default label.
Sourcepub fn label_kind(&self, label: &str) -> Option<LabelKind>
pub fn label_kind(&self, label: &str) -> Option<LabelKind>
The kind of a registered or default label. A user label persisted before kinds were recorded, and whose entities are all gone, reports as a vertex label until its next use records the kind.
Sourcepub fn register_label(
&mut self,
label: &str,
kind: LabelKind,
) -> GraphStoreResult<Option<u32>>
pub fn register_label( &mut self, label: &str, kind: LabelKind, ) -> GraphStoreResult<Option<u32>>
Register an empty user label ahead of any entity, as
create_vlabel / create_elabel do. Returns the new label id;
None when the name is already a label of this graph.
Sourcepub fn remove_label(&mut self, label: &str) -> Option<u32>
pub fn remove_label(&mut self, label: &str) -> Option<u32>
Forget a label. Default labels leave a durable tombstone so the graph
can continue to exist without their AGE relations. Returns the
released label id, or None when the label is not registered.
Sourcepub fn labels(&self) -> Vec<GraphLabelInfo>
pub fn labels(&self) -> Vec<GraphLabelInfo>
Every present label of the graph in ag_label order: surviving
defaults first, then user labels by ascending label id.
Sourcepub fn merge(&mut self, other: &GraphLabelRegistry)
pub fn merge(&mut self, other: &GraphLabelRegistry)
Merge another registry (e.g. persisted metadata) into this one, keeping the larger sequence values and label id watermark.
Trait Implementations§
Source§impl Clone for GraphLabelRegistry
impl Clone for GraphLabelRegistry
Source§fn clone(&self) -> GraphLabelRegistry
fn clone(&self) -> GraphLabelRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more