Skip to main content

ColumnarStore

Struct ColumnarStore 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

pub fn is_tracked(&self, tag: &str) -> bool

Returns true if the given tag is tracked as a column.

Source

pub fn set(&mut self, eid: usize, tag: &str, value: &Kind)

Set the value for entity eid at the given tag column.

Source

pub fn clear_entity(&mut self, eid: usize)

Clear the value for entity eid at the given tag column.

Source

pub fn ensure_capacity(&mut self, new_capacity: usize)

Ensure all columns can hold at least new_capacity entries.

Source

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.

Source

pub fn get(&self, eid: usize, tag: &str) -> Option<&Kind>

Get the value for a specific entity and tag.

Source

pub fn scan_column<F>(&self, tag: &str, predicate: F) -> Vec<usize>
where F: Fn(&Kind) -> bool,

Scan a column and return entity IDs where the predicate matches. This is the primary performance advantage: sequential memory access.

Source

pub fn column_count(&self) -> usize

Number of tracked columns.

Source

pub fn capacity(&self) -> usize

Current capacity (max entity IDs).

Source

pub fn clear(&mut self)

Clear all column data (keeps tracked tags registered).

Source

pub fn tracked_tags(&self) -> &[String]

Tracked tag names.

Trait Implementations§

Source§

impl Default for ColumnarStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.