pub struct UnifiedRecord {
pub nodes: HashMap<String, MatchedNode>,
pub edges: HashMap<String, MatchedEdge>,
pub paths: Vec<GraphPath>,
pub vector_results: Vec<VectorSearchResult>,
/* private fields */
}Expand description
A single result record containing mixed data.
Per Roadmap #1 (issue #156), table-column data uses a
schema-shared layout: schema is an Arc<Vec<Arc<str>>> shared
across every record in one result (one alloc per query instead of
per row), and values is the parallel array — position i in
values corresponds to schema[i]. overflow materialises only
for ragged rows (schemaless inserts, post-creation set calls
for keys not in the schema, projections that mix in alias-prefixed
columns, etc.).
Keys throughout use Arc<str> so interned column names (system
fields, shared schema strings) reuse storage across millions of
records without per-row heap allocation — each Arc::clone is a
single atomic increment. HashMap<Arc<str>, V> lookups still
work with &str queries because Arc<str>: Borrow<str> and both
hash identically.
The nodes, edges, paths, and vector_results fields carry
graph-query results and are orthogonal to the table layout.
Fields§
§nodes: HashMap<String, MatchedNode>Matched nodes (for graph data)
edges: HashMap<String, MatchedEdge>Matched edges (for graph data)
paths: Vec<GraphPath>Paths (for path queries)
vector_results: Vec<VectorSearchResult>Vector search results
Implementations§
Source§impl UnifiedRecord
impl UnifiedRecord
Sourcepub fn new() -> UnifiedRecord
pub fn new() -> UnifiedRecord
Create an empty schemaless record. Any set* calls will land
in the overflow HashMap.
Sourcepub fn with_capacity(capacity: usize) -> UnifiedRecord
pub fn with_capacity(capacity: usize) -> UnifiedRecord
Create a schemaless record with pre-allocated capacity for the overflow HashMap. Use this when you know the writer will push many fields with no shared schema available.
Sourcepub fn with_schema(
schema: Arc<Vec<Arc<str>>>,
values: Vec<Value>,
) -> UnifiedRecord
pub fn with_schema( schema: Arc<Vec<Arc<str>>>, values: Vec<Value>, ) -> UnifiedRecord
Build a record from a shared schema and a parallel value
array. Scan hot paths use this — the schema Arc is reused
across millions of records, so each row pays only a refcount
bump on the schema and a Vec<Value> allocation.
The two slices must be the same length; mismatch is treated the same way the legacy HashMap path treated it (excess schema entries become absent columns; excess values are dropped). Callers in scan paths always supply a length-matched pair.
Sourcepub fn from_columnar(
schema: Arc<Vec<Arc<str>>>,
values: Vec<Value>,
) -> UnifiedRecord
pub fn from_columnar( schema: Arc<Vec<Arc<str>>>, values: Vec<Value>, ) -> UnifiedRecord
Backwards-compatible alias for [with_schema]. Older callers
(and the wire-encoding fast path) used from_columnar.
Sourcepub fn schemaless() -> UnifiedRecord
pub fn schemaless() -> UnifiedRecord
Build a schemaless record that materialises fields directly in the overflow HashMap. Useful for ad-hoc inserts where no schema is known up front.
Sourcepub fn columns(&self) -> &[Arc<str>]
pub fn columns(&self) -> &[Arc<str>]
Schema slice — the column names known up front for this record. Returns an empty slice for schemaless records.
Sourcepub fn schema_values(&self) -> &[Value]
pub fn schema_values(&self) -> &[Value]
Parallel value slice (same length as [columns] for
schema-bearing records).
Sourcepub fn set(&mut self, column: &str, value: Value)
pub fn set(&mut self, column: &str, value: Value)
Set a column value. Allocates an Arc<str> for the key; hot-path
callers with a pre-interned key should prefer [set_arc].
Sourcepub fn set_owned(&mut self, column: String, value: Value)
pub fn set_owned(&mut self, column: String, value: Value)
Set a column value from an already-owned String key. If the
key is in the shared schema the value lands in the parallel
Vec<Value>; otherwise it promotes to the overflow HashMap.
Sourcepub fn set_arc(&mut self, column: Arc<str>, value: Value)
pub fn set_arc(&mut self, column: Arc<str>, value: Value)
Set a column value using a pre-interned key. Zero allocation
for the key in the schema-hit path — just an atomic refcount
bump on the existing schema entry. Used by the scan lean path
for system fields like rid.
Sourcepub fn set_arc_if_absent(&mut self, column: Arc<str>, value: Value)
pub fn set_arc_if_absent(&mut self, column: Arc<str>, value: Value)
Set a column value using a pre-interned key only when the column
is not already present. Used for the rid-envelope timestamp
fields: a collection with WITH timestamps = true materialises
created_at / updated_at as managed row columns (millisecond
precision); the envelope’s own second-precision values must not
overwrite them. For collections without managed timestamps the
column is absent and the envelope value lands as before.
Sourcepub fn get(&self, column: &str) -> Option<&Value>
pub fn get(&self, column: &str) -> Option<&Value>
Get a column value. Checks the schema-shared layout first (scan fast-path), then the overflow HashMap so late-arriving columns still resolve.
When the schema has duplicate names — e.g. the sys key
created_at plus a user column also named created_at — the
LAST occurrence wins. This mirrors the pre-refactor
HashMap::insert behaviour where a later set(name, value)
overwrote an earlier one, so scan output still shows the
user-provided value in preference to the system timestamp.
Sourcepub fn field_count(&self) -> usize
pub fn field_count(&self) -> usize
Number of visible fields across both representations.
Sourcepub fn contains_column(&self, column: &str) -> bool
pub fn contains_column(&self, column: &str) -> bool
Whether the record has a field with this column name.
Sourcepub fn iter_fields(&self) -> Box<dyn Iterator<Item = (&Arc<str>, &Value)> + '_>
pub fn iter_fields(&self) -> Box<dyn Iterator<Item = (&Arc<str>, &Value)> + '_>
Iterate (name, value) pairs across schema-shared + overflow.
Schema rows come first in their schema order; overflow rows
follow in arbitrary order. Consumers that need deterministic
ordering should sort by name.
Sourcepub fn values_mut(&mut self) -> Box<dyn Iterator<Item = &mut Value> + '_>
pub fn values_mut(&mut self) -> Box<dyn Iterator<Item = &mut Value> + '_>
Mutable iteration over every visible value. Used by the few in-place rewriters (e.g. secret-payload decryption). The schema slot is rewritten in-place; overflow values likewise.
Sourcepub fn column_names(&self) -> Vec<Arc<str>>
pub fn column_names(&self) -> Vec<Arc<str>>
Collect column names (both representations) in a Vec.
Sourcepub fn columnar(&self) -> Option<ColumnarRow<'_>>
pub fn columnar(&self) -> Option<ColumnarRow<'_>>
Borrow the columnar view, if the record carries a non-empty
shared schema. Hot-path wire encoders use this to resolve
column-name → index once per response, then index into
values[] per row instead of paying an rposition scan on
every cell. Returns None when the record is purely
schemaless (overflow only).
Sourcepub fn columnar_schema(&self) -> Option<&Arc<Vec<Arc<str>>>>
pub fn columnar_schema(&self) -> Option<&Arc<Vec<Arc<str>>>>
Return the Arc<Vec<Arc<str>>> schema pointer (for identity
comparison) when the record carries a schema. Callers that
want to cache a schema-specific column-index map across
records can use Arc::as_ptr(...) on this value as the cache
key.
Sourcepub fn overflow_mut(&mut self) -> &mut HashMap<Arc<str>, Value>
pub fn overflow_mut(&mut self) -> &mut HashMap<Arc<str>, Value>
Mutable handle to the overflow HashMap, allocating it on first use. Callers that need to bulk-insert raw HashMap entries (legacy code that hasn’t been migrated) can use this.
Sourcepub fn overflow_entry_or_insert(&mut self, column: Arc<str>, value: Value)
pub fn overflow_entry_or_insert(&mut self, column: Arc<str>, value: Value)
Insert into overflow with a borrowed &str key. Useful for
migrating legacy record.values.entry(k).or_insert(v) calls.
Sourcepub fn set_node(&mut self, alias: &str, node: MatchedNode)
pub fn set_node(&mut self, alias: &str, node: MatchedNode)
Set a matched node
Sourcepub fn get_node(&self, alias: &str) -> Option<&MatchedNode>
pub fn get_node(&self, alias: &str) -> Option<&MatchedNode>
Get a matched node
Sourcepub fn set_edge(&mut self, alias: &str, edge: MatchedEdge)
pub fn set_edge(&mut self, alias: &str, edge: MatchedEdge)
Set a matched edge
Trait Implementations§
Source§impl Clone for UnifiedRecord
impl Clone for UnifiedRecord
Source§fn clone(&self) -> UnifiedRecord
fn clone(&self) -> UnifiedRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UnifiedRecord
impl Debug for UnifiedRecord
Source§impl Default for UnifiedRecord
impl Default for UnifiedRecord
Source§fn default() -> UnifiedRecord
fn default() -> UnifiedRecord
Auto Trait Implementations§
impl Forget for UnifiedRecord
impl Freeze for UnifiedRecordwhere
*const ArcInner<Vec<Arc<str>>> is !null: Freeze,
PhantomData<ArcInner<Vec<Arc<str>>>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<Value>: Freeze,
PhantomData<(Arc<str>, Value)>: Freeze,
PhantomData<(String, MatchedNode)>: Freeze,
PhantomData<(String, MatchedEdge)>: Freeze,
PhantomData<GraphPath>: Freeze,
PhantomData<VectorSearchResult>: Freeze,
impl Move for UnifiedRecord
impl RefUnwindSafe for UnifiedRecord
impl Send for UnifiedRecord
impl Sync for UnifiedRecord
impl Unpin for UnifiedRecord
impl UnsafeUnpin for UnifiedRecordwhere
*const ArcInner<Vec<Arc<str>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<Arc<str>>>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
PhantomData<(Arc<str>, Value)>: UnsafeUnpin,
PhantomData<(String, MatchedNode)>: UnsafeUnpin,
PhantomData<(String, MatchedEdge)>: UnsafeUnpin,
PhantomData<GraphPath>: UnsafeUnpin,
PhantomData<VectorSearchResult>: UnsafeUnpin,
impl UnwindSafe for UnifiedRecordwhere
Arc<Vec<Arc<str>>>: UnwindSafe,
RawVecInner: UnwindSafe,
Arc<str>: UnwindSafe,
Arc<CronSchedule>: UnwindSafe,
HashMap<Arc<str>, Value>: UnwindSafe,
HashMap<String, MatchedNode>: UnwindSafe,
HashMap<String, MatchedEdge>: UnwindSafe,
HashMap<String, Value>: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request