pub struct ColumnarCache { /* private fields */ }Expand description
Tier 2: Columnar cache for OLAP queries
Implementations§
Source§impl ColumnarCache
impl ColumnarCache
Sourcepub fn with_memory_limit(max_memory: usize) -> Self
pub fn with_memory_limit(max_memory: usize) -> Self
Create a new Columnar Cache with custom memory limit.
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Get current memory usage in bytes.
Sourcepub fn memory_limit(&self) -> usize
pub fn memory_limit(&self) -> usize
Get memory limit in bytes.
Sourcepub fn should_evict(&self) -> bool
pub fn should_evict(&self) -> bool
Check if cache should evict entries.
Sourcepub fn persist_to_disk(&self, table: &str, cache_dir: &str) -> DbxResult<()>
pub fn persist_to_disk(&self, table: &str, cache_dir: &str) -> DbxResult<()>
Persist table cache to disk using Arrow IPC format
§Performance
- Eliminates JSON parsing on restart (50-70% faster)
- Zero-copy deserialization
Sourcepub fn load_from_disk(
&self,
table: &str,
cache_dir: &str,
) -> DbxResult<Vec<RecordBatch>>
pub fn load_from_disk( &self, table: &str, cache_dir: &str, ) -> DbxResult<Vec<RecordBatch>>
Load table cache from disk using Arrow IPC format
§Performance
- ~0.5µs per batch (vs JSON: ~10µs)
- Zero-copy: direct memory mapping
Sourcepub fn clear_disk_cache(&self, table: &str, cache_dir: &str) -> DbxResult<()>
pub fn clear_disk_cache(&self, table: &str, cache_dir: &str) -> DbxResult<()>
Clear persisted cache files for a table
Sourcepub fn insert_batch(&self, table: &str, batch: RecordBatch) -> DbxResult<()>
pub fn insert_batch(&self, table: &str, batch: RecordBatch) -> DbxResult<()>
Insert a RecordBatch into the cache as Raw (Binary) data.
Sourcepub fn sync_from_storage(
&self,
table: &str,
rows: Vec<(Vec<u8>, Vec<u8>)>,
table_schema: Option<SchemaRef>,
) -> DbxResult<usize>
pub fn sync_from_storage( &self, table: &str, rows: Vec<(Vec<u8>, Vec<u8>)>, table_schema: Option<SchemaRef>, ) -> DbxResult<usize>
Sync data from storage tiers to Columnar Cache.
If table_schema is provided, converts data to typed format (SQL table). Otherwise, stores as raw Binary format (CRUD data).
Sourcepub fn get_batches_with_filter<F>(
&self,
table: &str,
projection: Option<&[usize]>,
filter: F,
) -> DbxResult<Option<Vec<RecordBatch>>>
pub fn get_batches_with_filter<F>( &self, table: &str, projection: Option<&[usize]>, filter: F, ) -> DbxResult<Option<Vec<RecordBatch>>>
Get batches with filter pushdown.
The filter closure takes a full RecordBatch and returns a BooleanArray (mask). Rows where mask is true are kept.
Sourcepub fn get_batches(
&self,
table: &str,
projection: Option<&[usize]>,
) -> DbxResult<Option<Vec<RecordBatch>>>
pub fn get_batches( &self, table: &str, projection: Option<&[usize]>, ) -> DbxResult<Option<Vec<RecordBatch>>>
Get all batches for a table with optional column projection.
Sourcepub fn clear_table(&self, table: &str) -> DbxResult<()>
pub fn clear_table(&self, table: &str) -> DbxResult<()>
Clear all cached data for a table.
Sourcepub fn get_schema(&self, table: &str) -> Option<SchemaRef>
pub fn get_schema(&self, table: &str) -> Option<SchemaRef>
Get schema for a table.
Sourcepub fn table_names(&self) -> Vec<String>
pub fn table_names(&self) -> Vec<String>
Get list of cached tables.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ColumnarCache
impl !RefUnwindSafe for ColumnarCache
impl Send for ColumnarCache
impl Sync for ColumnarCache
impl Unpin for ColumnarCache
impl UnsafeUnpin for ColumnarCache
impl !UnwindSafe for ColumnarCache
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
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>
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>
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