pub struct UnifiedEntity {
pub id: EntityId,
pub kind: EntityKind,
pub created_at: u64,
pub updated_at: u64,
pub data: EntityData,
pub sequence_id: u64,
pub field_bloom: u64,
pub xmin: u64,
pub xmax: u64,
/* private fields */
}Expand description
A unified entity that can represent any storage type
Fields§
§id: EntityIdUnique entity identifier
kind: EntityKindWhat kind of entity this is
created_at: u64Creation timestamp
updated_at: u64Last update timestamp
data: EntityDataThe actual data content
sequence_id: u64Sequence ID for ordering/versioning
field_bloom: u64Field-name bloom filter (u64, zero-allocation).
Each bit encodes one possible mid-character value: for field name n
the bit position is n.as_bytes()[n.len()/2] & 63. OR of all user
field names present in this entity. Cleared for schema-based bulk rows
(all rows share the same schema so bloom is segment-level).
The compiled filter computes required_bloom from predicate field names
at compile time. If entity.field_bloom & required_bloom != required_bloom,
the entity cannot match and is skipped before any HashMap probe.
xmin: u64MVCC creation transaction ID (Phase 2.3 PG parity).
0 means “pre-MVCC” / auto-commit — visible to every snapshot. When
a BEGIN-wrapped INSERT runs, it stamps xmin with the transaction’s
snapshot id so other concurrent transactions only see the row after
the writer commits (snapshot isolation semantics).
Visibility rule: xmin <= snapshot.xid && (xmax == 0 || xmax > snapshot.xid).
xmax: u64MVCC deletion transaction ID (Phase 2.3 PG parity).
0 means “live”. Set to the deleting transaction’s snapshot id on
DELETE/UPDATE (row is kept until VACUUM reclaims it). Snapshots with
xid < xmax still see the row; newer snapshots skip it.
Implementations§
Source§impl UnifiedEntity
impl UnifiedEntity
Sourcepub fn embeddings(&self) -> &[EmbeddingSlot]
pub fn embeddings(&self) -> &[EmbeddingSlot]
Access embeddings (returns empty slice if no aux data).
Sourcepub fn cross_refs(&self) -> &[CrossRef]
pub fn cross_refs(&self) -> &[CrossRef]
Access cross-references (returns empty slice if no aux data).
Sourcepub fn embeddings_mut(&mut self) -> &mut Vec<EmbeddingSlot>
pub fn embeddings_mut(&mut self) -> &mut Vec<EmbeddingSlot>
Get mutable embeddings (allocates aux if needed).
Sourcepub fn cross_refs_mut(&mut self) -> &mut Vec<CrossRef>
pub fn cross_refs_mut(&mut self) -> &mut Vec<CrossRef>
Get mutable cross-refs (allocates aux if needed).
Source§impl UnifiedEntity
impl UnifiedEntity
Sourcepub fn new(id: EntityId, kind: EntityKind, data: EntityData) -> Self
pub fn new(id: EntityId, kind: EntityKind, data: EntityData) -> Self
Create a new unified entity
Sourcepub fn is_visible(&self, snapshot_xid: u64) -> bool
pub fn is_visible(&self, snapshot_xid: u64) -> bool
MVCC visibility check (Phase 2.3 PG parity).
Returns true when this tuple is visible under the provided
snapshot xid. Pre-MVCC rows (xmin == 0, xmax == 0) are visible
to every snapshot — preserves full compatibility with existing
data inserted before the MVCC headers existed.
Snapshot isolation rule:
xmin == 0 || xmin <= snapshot_xid(creator committed before snapshot)xmax == 0 || xmax > snapshot_xid(deleter committed after snapshot)
Sourcepub fn set_xmin(&mut self, xid: u64)
pub fn set_xmin(&mut self, xid: u64)
Stamp xmin (creation transaction ID). Called by the runtime on
INSERT inside an active transaction.
Sourcepub fn set_xmax(&mut self, xid: u64)
pub fn set_xmax(&mut self, xid: u64)
Stamp xmax (deletion transaction ID). Called by the runtime on
DELETE/UPDATE inside an active transaction — the tuple survives
until VACUUM reclaims it.
Sourcepub fn logical_id(&self) -> EntityId
pub fn logical_id(&self) -> EntityId
Stable user-visible identity. Legacy rows without an explicit logical id map to their physical entity id.
Sourcepub fn has_explicit_logical_id(&self) -> bool
pub fn has_explicit_logical_id(&self) -> bool
Returns true when the entity carries an explicit logical id on disk.
Sourcepub fn set_logical_id(&mut self, logical_id: EntityId)
pub fn set_logical_id(&mut self, logical_id: EntityId)
Set the stable user-visible identity for this physical version.
Sourcepub fn ensure_table_logical_id(&mut self)
pub fn ensure_table_logical_id(&mut self)
Ensure entities written by the current engine carry explicit
logical identity. Table rows + documents (Phase 1/2) and graph
nodes/edges (Phase 3) participate in the multi-model MVCC
versioning rollout and so need a stable logical id for
version-chain selection. Stamping the logical id is inert for
non-versioned collections: history only accrues through
install_versioned_table_row_update, which is gated on the
collection versioned flag, so a stamped-but-never-superseded
entity keeps logical_id == id and behaves exactly as before.
Vectors are intentionally excluded pending their read-path follow
up (no snapshot-honoring VECTOR SEARCH).
Sourcepub fn table_row(
id: EntityId,
table: impl Into<Arc<str>>,
row_id: u64,
columns: Vec<Value>,
) -> Self
pub fn table_row( id: EntityId, table: impl Into<Arc<str>>, row_id: u64, columns: Vec<Value>, ) -> Self
Create a table row entity
Sourcepub fn graph_node(
id: EntityId,
label: impl Into<String>,
node_type: impl Into<String>,
properties: HashMap<String, Value>,
) -> Self
pub fn graph_node( id: EntityId, label: impl Into<String>, node_type: impl Into<String>, properties: HashMap<String, Value>, ) -> Self
Create a graph node entity
Sourcepub fn graph_edge(
id: EntityId,
label: impl Into<String>,
from: impl Into<String>,
to: impl Into<String>,
weight: f32,
properties: HashMap<String, Value>,
) -> Self
pub fn graph_edge( id: EntityId, label: impl Into<String>, from: impl Into<String>, to: impl Into<String>, weight: f32, properties: HashMap<String, Value>, ) -> Self
Create a graph edge entity
Sourcepub fn vector(
id: EntityId,
collection: impl Into<String>,
vector: Vec<f32>,
) -> Self
pub fn vector( id: EntityId, collection: impl Into<String>, vector: Vec<f32>, ) -> Self
Create a vector entity
Sourcepub fn add_embedding(&mut self, slot: EmbeddingSlot)
pub fn add_embedding(&mut self, slot: EmbeddingSlot)
Add an embedding to this entity
Sourcepub fn add_cross_ref(&mut self, cross_ref: CrossRef)
pub fn add_cross_ref(&mut self, cross_ref: CrossRef)
Add a cross-reference
Sourcepub fn get_embedding(&self, name: &str) -> Option<&EmbeddingSlot>
pub fn get_embedding(&self, name: &str) -> Option<&EmbeddingSlot>
Get embedding by slot name
Source§impl UnifiedEntity
impl UnifiedEntity
Sourcepub fn from_properties(
id: EntityId,
label: impl Into<String>,
node_type: impl Into<String>,
properties: impl IntoIterator<Item = (impl Into<String>, Value)>,
) -> Self
pub fn from_properties( id: EntityId, label: impl Into<String>, node_type: impl Into<String>, properties: impl IntoIterator<Item = (impl Into<String>, Value)>, ) -> Self
Create a graph node entity from properties map
Sourcepub fn into_vector(self) -> Option<VectorData>
pub fn into_vector(self) -> Option<VectorData>
Convert entity to vector data if applicable