pub struct StorageEngine { /* private fields */ }Expand description
Storage engine for Arrow/Parquet data
Implementations§
Source§impl StorageEngine
impl StorageEngine
Sourcepub const fn new(batches: Vec<RecordBatch>) -> Self
pub const fn new(batches: Vec<RecordBatch>) -> Self
Create a new storage engine from existing batches
Useful for testing and benchmarking
Sourcepub fn load_parquet<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load_parquet<P: AsRef<Path>>(path: P) -> Result<Self>
Sourcepub fn batches(&self) -> &[RecordBatch]
pub fn batches(&self) -> &[RecordBatch]
Get all record batches
Sourcepub fn morsels(&self) -> MorselIterator<'_> ⓘ
pub fn morsels(&self) -> MorselIterator<'_> ⓘ
Create iterator over morsels (128MB chunks)
Sourcepub fn append_batch(&mut self, batch: RecordBatch) -> Result<()>
pub fn append_batch(&mut self, batch: RecordBatch) -> Result<()>
Append batches to storage (OLAP-optimized)
WARNING: This is the ONLY supported write operation. Trueno-DB does NOT support incremental row updates (OLTP).
§Design Rationale
Columnar storage optimizes for bulk reads, not random writes:
- Single-row update cost: O(N) (rewrite entire column)
- Batch append cost: O(1) (append to new partition)
§Example
// Good: Bulk append (OLAP-compatible)
let schema = Arc::new(Schema::new(vec![
Field::new("id", DataType::Int32, false),
]));
let batch = RecordBatch::try_new(
schema,
vec![Arc::new(Int32Array::from(vec![1, 2, 3]))],
)?;
let mut storage = StorageEngine::new(vec![]);
storage.append_batch(batch)?;§Errors
Returns error if batch schema doesn’t match existing batches
Sourcepub fn update_row(&mut self, _row_id: usize, _values: RecordBatch) -> Result<()>
👎Deprecated since 0.1.0: Trueno-DB is OLAP-only. Use append_batch() for bulk data loads.
pub fn update_row(&mut self, _row_id: usize, _values: RecordBatch) -> Result<()>
DEPRECATED: Single-row update not supported
Trueno-DB is OLAP-only (columnar storage). Use append_batch instead.
§Why This Fails
Column stores are optimized for bulk reads, not random writes:
SQLite(row-store):O(1)update withB-treeindexTrueno-DB(column-store):O(N)update (rewrite entire column)
§Migration Guide
// Bad: Incremental update (OLTP pattern)
// storage.update_row(row_id, new_values)?; // NOT SUPPORTED
// Good: Batch re-analysis (OLAP pattern)
let schema = Arc::new(Schema::new(vec![
Field::new("id", DataType::Int32, false),
]));
let new_batch = RecordBatch::try_new(
schema,
vec![Arc::new(Int32Array::from(vec![1, 2, 3]))],
)?;
let mut storage = StorageEngine::new(vec![]);
storage.append_batch(new_batch)?;§Errors
Always returns error (not implemented)
Auto Trait Implementations§
impl Freeze for StorageEngine
impl !RefUnwindSafe for StorageEngine
impl Send for StorageEngine
impl Sync for StorageEngine
impl Unpin for StorageEngine
impl UnsafeUnpin for StorageEngine
impl !UnwindSafe for StorageEngine
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