Struct Tuples

Source
pub struct Tuples { /* private fields */ }
Expand description

In-memory Tuple store.

  • Stores exactly one copy of each tuple
  • Allows for indexes on projections of the tuple (projections)
  • Allows for differential indexes on projections of the tuple (mailboxes)

Implementations§

Source§

impl Tuples

Source

pub fn force(&mut self)

Take all the delayed tuples and update the indices. Must be called prior to requesting a projection

Source

pub fn projection(&self, fields: &[usize]) -> &Projection

Acquires a previously registered projection for the permutation provided. If you did not register the projection, an assertion will trip.

Source

pub fn mailbox(&mut self, mailbox: usize) -> Projection

Acquires the index at a previously registered mailbox, emptying it out and returning the projection that was there.

Source

pub fn register_projection(&mut self, fields: &[usize])

Requests that a projection be made available for a given permutation. This is essentially analogous to asking a database to produce an index on a specific order or fields. Multiple requests for the same index ordering are idempotent.

Source

pub fn register_mailbox(&mut self, fields: &[usize]) -> usize

Requests that a mailbox be created for a given permutation, and returns the mailbox ID. A mailbox is basically an index for which only values added since you last checked it are present. Unlike register_projection, register_mailbox is not idempotent, since multiple clients may want to listen on the same order of fields. It will return a new mailbox ID every time.

Source

pub fn new(m_aggs: Vec<Option<Box<dyn Aggregator + 'static>>>) -> Self

Constructs a new Tuples tuplestore of the provided arity.

Source

pub fn arity(&self) -> usize

Returns the arity of the tuples stored

Source

pub fn len(&self) -> usize

Returns the number of elements stored

Source

pub fn find(&self, needle: &[usize]) -> Option<usize>

Provides the ID for a given tuple if it is present The provided needle must have an arity equal to the Tuples object

Source

pub fn get(&self, key: usize) -> Vec<usize>

Get the fact referenced by the provided key

Source

pub fn get_provenance(&self, key: usize) -> &BTreeSet<Provenance>

Return the set of ways this tuple was derived

Source

pub fn get_meta(&self, mid: MetaId) -> Vec<FactId>

Gets the list of fact IDs making up a particular meta-fact

Source

pub fn make_meta(&mut self, fids: &[FactId]) -> MetaId

Creates or references a MetaId for a circumscription over facts in this tuplestore

Source

pub fn purge_mid_prov<F: Fn(usize, usize) -> usize>( &mut self, fid: FactId, pred_id: usize, dep_mid: MetaId, f: F, ) -> (Option<FactId>, Option<MetaId>)

Cleanses a fact’s derivations of references to a MetaId

Source

pub fn purge_fid_prov<F: Fn(usize, usize) -> usize>( &mut self, fid: FactId, pred_id: usize, dep_fid: FactId, f: F, ) -> (Option<FactId>, Option<MetaId>)

Cleanses a fact’s derivations of references to a FactId

Source

pub fn insert( &mut self, val: &[usize], p: Provenance, ) -> (FactId, bool, Option<MetaId>)

Adds a new element to the tuple store. The arity of the provided value must equal the arity of the tuple store. The returned value is a tuple of the key, whether the value was new (true for new), and any MetaId that got broken by the insert

Auto Trait Implementations§

§

impl Freeze for Tuples

§

impl !RefUnwindSafe for Tuples

§

impl !Send for Tuples

§

impl !Sync for Tuples

§

impl Unpin for Tuples

§

impl !UnwindSafe for Tuples

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, 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.