pub struct ColumnarStore { /* private fields */ }Expand description
Column-oriented storage for entity tags, indexed by entity ID.
Each “column” is a Vec<Option<Kind>> where index i corresponds to
entity ID i. Missing entities or missing tags for that entity are None.
Benefits:
- Sequential memory access when scanning a single tag across all entities
- Cache-line prefetching works optimally (no pointer chasing through HDict)
- Natural alignment with bitmap indexes (same entity ID space)
Implementations§
Source§impl ColumnarStore
impl ColumnarStore
pub fn new() -> Self
Sourcepub fn track_tag(&mut self, tag: &str)
pub fn track_tag(&mut self, tag: &str)
Register a tag to be tracked as a column. Must call rebuild() after
registering new tags to populate from existing entities.
Sourcepub fn is_tracked(&self, tag: &str) -> bool
pub fn is_tracked(&self, tag: &str) -> bool
Returns true if the given tag is tracked as a column.
Sourcepub fn set(&mut self, eid: usize, tag: &str, value: &Kind)
pub fn set(&mut self, eid: usize, tag: &str, value: &Kind)
Set the value for entity eid at the given tag column.
Sourcepub fn clear_entity(&mut self, eid: usize)
pub fn clear_entity(&mut self, eid: usize)
Clear the value for entity eid at the given tag column.
Sourcepub fn ensure_capacity(&mut self, new_capacity: usize)
pub fn ensure_capacity(&mut self, new_capacity: usize)
Ensure all columns can hold at least new_capacity entries.
Sourcepub fn column(&self, tag: &str) -> Option<&[Option<Kind>]>
pub fn column(&self, tag: &str) -> Option<&[Option<Kind>]>
Get a column slice for a tracked tag. Returns None if the tag is not tracked.
Sourcepub fn get(&self, eid: usize, tag: &str) -> Option<&Kind>
pub fn get(&self, eid: usize, tag: &str) -> Option<&Kind>
Get the value for a specific entity and tag.
Sourcepub fn scan_column<F>(&self, tag: &str, predicate: F) -> Vec<usize>
pub fn scan_column<F>(&self, tag: &str, predicate: F) -> Vec<usize>
Scan a column and return entity IDs where the predicate matches. This is the primary performance advantage: sequential memory access.
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Number of tracked columns.
Tracked tag names.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ColumnarStore
impl RefUnwindSafe for ColumnarStore
impl Send for ColumnarStore
impl Sync for ColumnarStore
impl Unpin for ColumnarStore
impl UnsafeUnpin for ColumnarStore
impl UnwindSafe for ColumnarStore
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> 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