pub struct PackedRow { /* private fields */ }Expand description
Packed row format with O(1) column access
Memory Layout:
[null_bitmap: ⌈k/8⌉ bytes][offsets: 4×k bytes][col_data...]Total overhead: ⌈k/8⌉ + 4k bytes
Implementations§
Source§impl PackedRow
impl PackedRow
Sourcepub fn pack_slice(
schema: &PackedTableSchema,
values: &[Option<&SochValue>],
) -> Self
pub fn pack_slice( schema: &PackedTableSchema, values: &[Option<&SochValue>], ) -> Self
Pack values from a slice - zero allocation on caller side
§Arguments
schema- Table schema defining column order and typesvalues- Slice of optional values in column order (None = NULL)
§Performance
- Eliminates HashMap construction overhead (~6 allocations per row)
- Uses stack buffer for small rows (< 512 bytes)
- ~2-3× faster than pack() for bulk inserts
Sourcepub fn unpack_to_vec(&self, schema: &PackedTableSchema) -> Vec<SochValue>
pub fn unpack_to_vec(&self, schema: &PackedTableSchema) -> Vec<SochValue>
Unpack to Vec
Returns values in schema column order. Use when you need to iterate over all columns without the overhead of HashMap lookups.
Sourcepub fn get_column(
&self,
idx: usize,
col_type: PackedColumnType,
) -> Option<SochValue>
pub fn get_column( &self, idx: usize, col_type: PackedColumnType, ) -> Option<SochValue>
Sourcepub fn get_by_name(
&self,
schema: &PackedTableSchema,
name: &str,
) -> Option<SochValue>
pub fn get_by_name( &self, schema: &PackedTableSchema, name: &str, ) -> Option<SochValue>
Get column by name using schema
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Get raw bytes as owned vector
Sourcepub fn from_bytes(data: Vec<u8>, num_cols: usize) -> Result<Self>
pub fn from_bytes(data: Vec<u8>, num_cols: usize) -> Result<Self>
Reconstruct a PackedRow from bytes
§Arguments
data- Raw bytes from storagenum_cols- Number of columns in the schema
Sourcepub fn unpack(&self, schema: &PackedTableSchema) -> HashMap<String, SochValue>
pub fn unpack(&self, schema: &PackedTableSchema) -> HashMap<String, SochValue>
Unpack all columns into a HashMap
Sourcepub fn num_columns(&self) -> usize
pub fn num_columns(&self) -> usize
Get the number of columns
Auto Trait Implementations§
impl Freeze for PackedRow
impl RefUnwindSafe for PackedRow
impl Send for PackedRow
impl Sync for PackedRow
impl Unpin for PackedRow
impl UnsafeUnpin for PackedRow
impl UnwindSafe for PackedRow
Blanket Implementations§
impl<T> Allocation for T
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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 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>
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