Rindle docs and package mapSkip to main content

OwnedRow

Struct OwnedRow 

pub struct OwnedRow { /* private fields */ }
Expand description

An owned row: an index-addressed, immutable, cheaply-clonable value sequence, stored as one flat allocation (205-FLAT-ROW-SINGLE-BUFFER-DESIGN.md). Cloning a row into an overlay / the view / a heap is a refcount bump, not a deep copy (shared-row aliasing is pervasive) — exactly as when this was Arc<[OwnedValue]>, but the cells now live inline in the row’s own buffer (no per-Str-cell Arc<str> block), so materializing a row is one allocation instead of 2 + k_text.

Layout (all integers little-endian):

[0..4)      n: u32                       cell count
[4..4+9n)   directory, 9 bytes per cell: [tag u8][payload 8B]
              Absent/Null: payload unused          Bool: payload[0]
              Int: i64                             Float: f64 bits
              Str/Json: [off u32][len u32]  (absolute into the buffer)
[4+9n..)    Str/Json bytes, concatenated in cell order

Cells are read as borrowed Value<'_>s via OwnedRow::colStr/Json borrow the row’s own buffer zero-copy. Text bytes are UTF-8-validated at construction (the same eager timing as the old per-cell Value::try_to_owned), so readers never re-validate.

Implementations§

§

impl OwnedRow

pub fn len(&self) -> usize

Number of cells.

pub fn is_empty(&self) -> bool

pub fn col(&self, c: usize) -> Value<'_>

Read cell c, zero-copy. Panics if c is out of range — the same contract as the old slice index (ColIds are resolved against the schema at build time, so an out-of-range read is a builder bug).

#[inline(always)] + the out-of-line panic are load-bearing: this is the cell accessor inside compare_rows, i.e. inside every btree node compare on the write path. One fused 9-byte cell slice (a single bounds check) instead of separate tag/payload indexing keeps it a handful of instructions.

pub fn get(&self, c: usize) -> Option<Value<'_>>

Read cell c, or None if out of range (the tolerant peer of OwnedRow::col — the wasm marshal reads short/projected rows with it).

pub fn cells(&self) -> impl ExactSizeIterator

Iterate the cells as borrowed Value<'_>s (replaces .iter() over the old &[OwnedValue] view).

pub fn ptr_eq(a: &OwnedRow, b: &OwnedRow) -> bool

Row identity (not equality): do two rows share the same buffer? The btree’s COW-refresh and structural-diff fast paths use this exactly as they used Arc::ptr_eq on the old Arc<[OwnedValue]>.

pub fn byte_len(&self) -> usize

The size of the row’s single heap buffer in bytes (header + directory + text region) — the row’s entire heap footprint besides the Arc header. Memory accounting (e.g. rindle-loadgen) reads this instead of modeling per-cell blocks, which no longer exist.

pub fn empty() -> OwnedRow

The shared zero-column row (ghost/placeholder entries). O(1), allocates once per process.

pub fn to_value_vec(&self) -> Vec<OwnedValue>

Materialize every cell as an OwnedValue (the wire / compatibility escape — allocates per Str/Json cell).

pub fn from_owned_cells(cells: &[OwnedValue]) -> OwnedRow

Build a row from already-owned cells. Infallible: an OwnedValue::Str/Json is Arc<str>, so its bytes are valid UTF-8 by construction — no validation pass.

pub fn try_from_row_ref<R>(r: &R) -> Result<OwnedRow, RindleError>
where R: RowRef + ?Sized,

The leaf-boundary constructor: materialize a borrowed row (e.g. the SQLite step buffer) into one flat allocation, validating Str/Json UTF-8 exactly once — the same eager timing as the old per-cell Value::try_to_owned, but with no per-cell allocation. Errors surface before the row allocates.

Trait Implementations§

§

impl Clone for OwnedRow

§

fn clone(&self) -> OwnedRow

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
§

impl Debug for OwnedRow

§

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

Formats the value using the given formatter. Read more
§

impl RowRef for &OwnedRow

THE canonical owned→borrowed bridge for the memory backend. Vending a &OwnedRow (rather than a &[OwnedValue] slice) is what makes to_owned_row an O(1) Arc bump instead of a deep copy — folding the btree spike’s current_arc escape hatch (04 OQ-2) into the shared trait. The BTreeCursor sets type Row<'a> = &'a OwnedRow and gets owning-at-the-node -boundary for free.

§

fn col(&self, c: usize) -> Value<'_>

Read column c, zero-copy.
§

fn len(&self) -> usize

Number of columns.
§

fn to_owned_row(&self) -> OwnedRow

Materialize the whole row. For the held-Rc memory backend this is an O(1) Arc bump (the impl on &OwnedRow below); for the SQLite leaf it is the one forced per-row copy out of the step buffer (sqlite.rs).
§

fn is_empty(&self) -> bool

§

fn try_to_owned_row(&self) -> Result<OwnedRow, RindleError>

Fallible materialization for external data. Memory-backed rows override nothing because owning is an Arc bump; SQLite rows override this to surface invalid text/json as RindleError instead of panicking.

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