Skip to main content

FactorizedData

Trait FactorizedData 

Source
pub trait FactorizedData: Send + Sync {
    // Required methods
    fn chunk_state(&self) -> &ChunkState;
    fn logical_row_count(&self) -> usize;
    fn physical_size(&self) -> usize;
    fn is_factorized(&self) -> bool;
    fn flatten(&self) -> DataChunk;
    fn as_factorized(&self) -> Option<&FactorizedChunk>;
    fn as_flat(&self) -> Option<&DataChunk>;
}
Expand description

Trait for data that can be in factorized or flat form.

This provides a common interface for operators that need to handle both representations without caring which is used. Inspired by LadybugDB’s unified data model.

§Example

fn process_data(data: &dyn FactorizedData) {
    if data.is_factorized() {
        // Handle factorized path
        let chunk = data.as_factorized().unwrap();
        // ... use factorized chunk directly
    } else {
        // Handle flat path
        let chunk = data.flatten();
        // ... process flat chunk
    }
}

Required Methods§

Source

fn chunk_state(&self) -> &ChunkState

Returns the chunk state (factorization status, cached data).

Source

fn logical_row_count(&self) -> usize

Returns the logical row count (considering selection).

Source

fn physical_size(&self) -> usize

Returns the physical size (actual stored values).

Source

fn is_factorized(&self) -> bool

Returns true if this data is factorized (multi-level).

Source

fn flatten(&self) -> DataChunk

Flattens to a DataChunk (materializes if factorized).

Source

fn as_factorized(&self) -> Option<&FactorizedChunk>

Returns as FactorizedChunk if factorized, None if flat.

Source

fn as_flat(&self) -> Option<&DataChunk>

Returns as DataChunk if flat, None if factorized.

Implementors§