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
impl Tuples
Sourcepub fn force(&mut self)
pub fn force(&mut self)
Take all the delayed tuples and update the indices. Must be called prior to requesting a projection
Sourcepub fn projection(&self, fields: &[usize]) -> &Projection
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.
Sourcepub fn mailbox(&mut self, mailbox: usize) -> Projection
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.
Sourcepub fn register_projection(&mut self, fields: &[usize])
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.
Sourcepub fn register_mailbox(&mut self, fields: &[usize]) -> usize
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.
Sourcepub fn new(m_aggs: Vec<Option<Box<dyn Aggregator + 'static>>>) -> Self
pub fn new(m_aggs: Vec<Option<Box<dyn Aggregator + 'static>>>) -> Self
Constructs a new Tuples tuplestore of the provided arity.
Sourcepub fn find(&self, needle: &[usize]) -> Option<usize>
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
Sourcepub fn get_provenance(&self, key: usize) -> &BTreeSet<Provenance>
pub fn get_provenance(&self, key: usize) -> &BTreeSet<Provenance>
Return the set of ways this tuple was derived
Sourcepub fn get_meta(&self, mid: MetaId) -> Vec<FactId> ⓘ
pub fn get_meta(&self, mid: MetaId) -> Vec<FactId> ⓘ
Gets the list of fact IDs making up a particular meta-fact
Sourcepub fn make_meta(&mut self, fids: &[FactId]) -> MetaId
pub fn make_meta(&mut self, fids: &[FactId]) -> MetaId
Creates or references a MetaId for a circumscription over facts in this tuplestore
Sourcepub 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>)
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
Sourcepub 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>)
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
Sourcepub fn insert(
&mut self,
val: &[usize],
p: Provenance,
) -> (FactId, bool, Option<MetaId>)
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