pub struct ChunkState { /* private fields */ }Expand description
Unified chunk state tracking metadata for factorized execution.
This replaces scattered state tracking with a centralized structure that is updated incrementally rather than recomputed.
§Key Features
- Cached multiplicities: Computed once per chunk, reused for all aggregates
- Selection integration: Supports lazy filtering without data copying
- Generation tracking: Enables cache invalidation on structure changes
Implementations§
Source§impl ChunkState
impl ChunkState
Sourcepub fn unflat(level_count: usize, logical_rows: usize) -> Self
pub fn unflat(level_count: usize, logical_rows: usize) -> Self
Creates an unflat (factorized) chunk state.
Sourcepub fn factorization_state(&self) -> FactorizationState
pub fn factorization_state(&self) -> FactorizationState
Returns the factorization state.
Sourcepub fn is_factorized(&self) -> bool
pub fn is_factorized(&self) -> bool
Returns true if this chunk is factorized (unflat).
Sourcepub fn logical_row_count(&self) -> usize
pub fn logical_row_count(&self) -> usize
Returns the logical row count.
If a selection is active, this returns the base logical row count (selection count must be computed separately with multiplicities).
Sourcepub fn level_count(&self) -> usize
pub fn level_count(&self) -> usize
Returns the number of factorization levels.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Returns the current generation (for cache validation).
Sourcepub fn selection(&self) -> Option<&FactorizedSelection>
pub fn selection(&self) -> Option<&FactorizedSelection>
Returns the selection, if any.
Sourcepub fn selection_mut(&mut self) -> &mut Option<FactorizedSelection>
pub fn selection_mut(&mut self) -> &mut Option<FactorizedSelection>
Returns mutable access to the selection.
Sourcepub fn set_selection(&mut self, selection: FactorizedSelection)
pub fn set_selection(&mut self, selection: FactorizedSelection)
Sets the selection.
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clears the selection.
Sourcepub fn set_state(&mut self, state: FactorizationState)
pub fn set_state(&mut self, state: FactorizationState)
Updates the state (e.g., after adding a level).
Sourcepub fn invalidate_cache(&mut self)
pub fn invalidate_cache(&mut self)
Invalidates cached data (call when structure changes).
Sourcepub fn get_or_compute_multiplicities<F>(&mut self, compute: F) -> Arc<[usize]>
pub fn get_or_compute_multiplicities<F>(&mut self, compute: F) -> Arc<[usize]>
Gets cached multiplicities, or computes and caches them.
This is the key optimization: multiplicities are computed once and reused for all aggregates (COUNT, SUM, AVG, etc.).
§Arguments
compute- Function to compute multiplicities if not cached
§Example
let mults = state.get_or_compute_multiplicities(|| {
chunk.compute_path_multiplicities_impl()
});Sourcepub fn cached_multiplicities(&self) -> Option<&Arc<[usize]>>
pub fn cached_multiplicities(&self) -> Option<&Arc<[usize]>>
Returns cached multiplicities without computing.
Returns None if not yet computed.
Sourcepub fn set_cached_multiplicities(&mut self, mults: Arc<[usize]>)
pub fn set_cached_multiplicities(&mut self, mults: Arc<[usize]>)
Sets the cached multiplicities directly.
Useful when multiplicities are computed externally.
Trait Implementations§
Source§impl Clone for ChunkState
impl Clone for ChunkState
Source§fn clone(&self) -> ChunkState
fn clone(&self) -> ChunkState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChunkState
impl Debug for ChunkState
Auto Trait Implementations§
impl Freeze for ChunkState
impl RefUnwindSafe for ChunkState
impl Send for ChunkState
impl Sync for ChunkState
impl Unpin for ChunkState
impl UnwindSafe for ChunkState
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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