pub struct Row { /* private fields */ }Expand description
A database row containing column values
Row provides methods for accessing and manipulating column values while maintaining type safety and consistency with the schema.
§Performance
Sharedstorage: O(1) clone (just Arc increment)Ownedstorage: O(n) clone (copies values)- String values use
SmartStringwith internalArc<str>for efficient sharing
Implementations§
Source§impl Row
impl Row
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a row with pre-allocated capacity
Sourcepub fn from_values(values: Vec<Value>) -> Self
pub fn from_values(values: Vec<Value>) -> Self
Create a row from a vector of values
Sourcepub fn from_compact_vec(values: CompactVec<Value>) -> Self
pub fn from_compact_vec(values: CompactVec<Value>) -> Self
Create a row from CompactVec<Value>
Sourcepub fn from_arc(values: CompactArc<[Value]>) -> Self
pub fn from_arc(values: CompactArc<[Value]>) -> Self
Create a row from an Arc slice - O(1), no copying
Sourcepub fn from_combined(left: &Row, right: &Row) -> Self
pub fn from_combined(left: &Row, right: &Row) -> Self
Create a row by combining two rows (for JOINs) Result uses Owned storage (optimal for intermediate results)
Sourcepub fn combine_into_owned(&mut self, left: Row, right: Row)
pub fn combine_into_owned(&mut self, left: Row, right: Row)
Combine rows: move both (for JOINs) - reuses allocation
Sourcepub fn from_combined_clone_move(left: &Row, right: Row) -> Self
pub fn from_combined_clone_move(left: &Row, right: Row) -> Self
Combine rows: clone left, move right (for JOINs)
Sourcepub fn from_combined_owned(left: Row, right: Row) -> Self
pub fn from_combined_owned(left: Row, right: Row) -> Self
Combine two owned rows (for JOINs) - moves values without cloning
Sourcepub fn null_row<S: RowSchema + ?Sized>(schema: &S) -> Self
pub fn null_row<S: RowSchema + ?Sized>(schema: &S) -> Self
Create a row with null values for a given schema
Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut Value>
pub fn get_mut(&mut self, index: usize) -> Option<&mut Value>
Get a mutable value by index (triggers copy-on-write if shared)
Sourcepub fn set(&mut self, index: usize, value: Value) -> Result<()>
pub fn set(&mut self, index: usize, value: Value) -> Result<()>
Set a value at the given index (triggers copy-on-write if shared)
Sourcepub fn take_and_clear(&mut self) -> Row
pub fn take_and_clear(&mut self) -> Row
Take the values from this row, returning them in a new Row. The original row is cleared but keeps its allocated capacity.
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserve capacity for at least additional more values
Sourcepub fn extend_from_slice(&mut self, other: &[Value])
pub fn extend_from_slice(&mut self, other: &[Value])
Extend the row with values from a slice
Sourcepub fn extend_into_compact_vec(self, target: &mut CompactVec<Value>)
pub fn extend_into_compact_vec(self, target: &mut CompactVec<Value>)
Extend a CompactVec with this row’s values, consuming self.
OPTIMIZATION: This avoids the intermediate Vec allocation that would occur
with target.extend(row) which goes through Row::into_iter().
- Owned storage: directly extends from CompactVec (moves values)
- Shared storage: clones values from Arc slice
Sourcepub fn iter_mut(&mut self) -> RowIterMut<'_> ⓘ
pub fn iter_mut(&mut self) -> RowIterMut<'_> ⓘ
Get a mutable iterator over the values (triggers copy-on-write if shared)
Sourcepub fn into_values(self) -> Vec<Value>
pub fn into_values(self) -> Vec<Value>
Get the underlying vector of values, consuming the row
Sourcepub fn take_first_value(self) -> Option<Value>
pub fn take_first_value(self) -> Option<Value>
Extract the first value, consuming the row
Check if storage is shared (Arc-wrapped)
Sourcepub fn into_arc(self) -> CompactArc<[Value]>
pub fn into_arc(self) -> CompactArc<[Value]>
Convert Row to CompactArc<Value>, consuming self
- Shared: returns the CompactArc directly (O(1))
- Owned: creates new Arc (O(n))
Sourcepub fn as_arc(&self) -> Option<&CompactArc<[Value]>>
pub fn as_arc(&self) -> Option<&CompactArc<[Value]>>
Get CompactArc<Value> reference if shared, None if owned
Sourcepub fn select_columns(&self, indices: &[usize]) -> Result<Row>
pub fn select_columns(&self, indices: &[usize]) -> Result<Row>
Extract specific columns by their indices
Sourcepub fn take_columns(self, indices: &[usize]) -> Result<Row>
pub fn take_columns(self, indices: &[usize]) -> Result<Row>
Take specific columns by their indices, consuming the row Detects prefix projections (0, 1, 2, …, n-1) and truncates in-place.
Sourcepub fn validate<S: RowSchema + ?Sized>(&self, schema: &S) -> Result<()>
pub fn validate<S: RowSchema + ?Sized>(&self, schema: &S) -> Result<()>
Validate the row against a schema
Sourcepub fn clone_subset(&self, indices: &[usize]) -> Result<Row>
pub fn clone_subset(&self, indices: &[usize]) -> Result<Row>
Clone the row, selecting only the specified column indices
Sourcepub fn clear_inline(&mut self)
pub fn clear_inline(&mut self)
Clear and use as inline storage (backwards compatibility)
Sourcepub fn push_inline(&mut self, value: Value)
pub fn push_inline(&mut self, value: Value)
Push to inline storage (backwards compatibility)
Sourcepub fn reserve_inline(&mut self, capacity: usize)
pub fn reserve_inline(&mut self, capacity: usize)
Reserve inline capacity (backwards compatibility)