Skip to main content

UnifiedRecord

Struct UnifiedRecord 

Source
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

Source

pub fn new() -> UnifiedRecord

Create an empty schemaless record. Any set* calls will land in the overflow HashMap.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn columns(&self) -> &[Arc<str>]

Schema slice — the column names known up front for this record. Returns an empty slice for schemaless records.

Source

pub fn schema_values(&self) -> &[Value]

Parallel value slice (same length as [columns] for schema-bearing records).

Source

pub fn overflow(&self) -> Option<&HashMap<Arc<str>, Value>>

Schemaless overflow map, if any.

Source

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].

Source

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.

Source

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 red_entity_id.

Source

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.

Source

pub fn field_count(&self) -> usize

Number of visible fields across both representations.

Source

pub fn contains_column(&self, column: &str) -> bool

Whether the record has a field with this column name.

Source

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.

Source

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.

Source

pub fn column_names(&self) -> Vec<Arc<str>>

Collect column names (both representations) in a Vec.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn set_node(&mut self, alias: &str, node: MatchedNode)

Set a matched node

Source

pub fn get_node(&self, alias: &str) -> Option<&MatchedNode>

Get a matched node

Source

pub fn set_edge(&mut self, alias: &str, edge: MatchedEdge)

Set a matched edge

Trait Implementations§

Source§

impl Clone for UnifiedRecord

Source§

fn clone(&self) -> UnifiedRecord

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnifiedRecord

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for UnifiedRecord

Source§

fn default() -> UnifiedRecord

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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