pub struct ColumnarTable { /* private fields */ }Expand description
Columnar table storage
Stores data in column-oriented format for analytical query performance. Each column is stored as a typed vector with a separate NULL bitmap.
§Example
use vibesql_storage::{Row, ColumnarTable};
use vibesql_types::SqlValue;
// Create rows
let rows = vec![
Row::new(vec![SqlValue::Integer(1), SqlValue::Double(3.14)]),
Row::new(vec![SqlValue::Integer(2), SqlValue::Double(2.71)]),
];
// Convert to columnar
let column_names = vec!["id".to_string(), "value".to_string()];
let columnar = ColumnarTable::from_rows(&rows, &column_names).unwrap();
// Access column data
assert_eq!(columnar.row_count(), 2);
assert_eq!(columnar.column_count(), 2);Implementations§
Source§impl ColumnarTable
impl ColumnarTable
Sourcepub fn from_rows(rows: &[Row], column_names: &[String]) -> Result<Self, String>
pub fn from_rows(rows: &[Row], column_names: &[String]) -> Result<Self, String>
Convert row-oriented data to columnar format (optimized single-pass)
§Arguments
rows- Vector of rows to convertcolumn_names- Names of columns in order
§Returns
Ok(ColumnarTable)on successErr(String)if column count mismatch or incompatible types
§Performance
O(n * m) single pass through all data
Sourcepub fn from_row_refs(
rows: &[&Row],
column_names: &[String],
) -> Result<Self, String>
pub fn from_row_refs( rows: &[&Row], column_names: &[String], ) -> Result<Self, String>
Create a ColumnarTable from a slice of row references
This is useful when you have filtered rows (e.g., skipping deleted rows) and want to avoid cloning the entire row just to pass to from_rows.
§Arguments
rows- Slice of row references to convertcolumn_names- Column names for the table schema
§Returns
Ok(ColumnarTable)on successErr(String)if column count mismatch or incompatible types
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Get the number of columns
Sourcepub fn get_column(&self, name: &str) -> Option<&ColumnData>
pub fn get_column(&self, name: &str) -> Option<&ColumnData>
Get column data by name
Sourcepub fn column_names(&self) -> &[String]
pub fn column_names(&self) -> &[String]
Get all column names
Sourcepub fn size_in_bytes(&self) -> usize
pub fn size_in_bytes(&self) -> usize
Estimate the memory size of this columnar table in bytes
This is used for memory budgeting in the columnar cache. The estimate includes:
- All column data (via ColumnData::size_in_bytes)
- HashMap overhead for columns
- Vec overhead for column_names
- String storage for column names
Trait Implementations§
Source§impl Clone for ColumnarTable
impl Clone for ColumnarTable
Source§fn clone(&self) -> ColumnarTable
fn clone(&self) -> ColumnarTable
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ColumnarTable
impl Debug for ColumnarTable
Auto Trait Implementations§
impl Freeze for ColumnarTable
impl RefUnwindSafe for ColumnarTable
impl Send for ColumnarTable
impl Sync for ColumnarTable
impl Unpin for ColumnarTable
impl UnwindSafe for ColumnarTable
Blanket Implementations§
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