Skip to main content

StorageEngine

Struct StorageEngine 

Source
pub struct StorageEngine { /* private fields */ }
Expand description

Storage engine for Arrow/Parquet data

Implementations§

Source§

impl StorageEngine

Source

pub const fn new(batches: Vec<RecordBatch>) -> Self

Create a new storage engine from existing batches

Useful for testing and benchmarking

Source

pub fn load_parquet<P: AsRef<Path>>(path: P) -> Result<Self>

Load table from Parquet file

§Errors

Returns error if file cannot be read or parsed

Source

pub fn batches(&self) -> &[RecordBatch]

Get all record batches

Source

pub fn morsels(&self) -> MorselIterator<'_>

Create iterator over morsels (128MB chunks)

Source

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

Source

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

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 with B-tree index
  • Trueno-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§

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,