Skip to main content

TribleSet

Struct TribleSet 

Source
pub struct TribleSet {
    pub eav: PATCH<TRIBLE_LEN, EAVOrder, ()>,
    pub vea: PATCH<TRIBLE_LEN, VEAOrder, ()>,
    pub ave: PATCH<TRIBLE_LEN, AVEOrder, ()>,
    pub vae: PATCH<TRIBLE_LEN, VAEOrder, ()>,
    pub eva: PATCH<TRIBLE_LEN, EVAOrder, ()>,
    pub aev: PATCH<TRIBLE_LEN, AEVOrder, ()>,
}
Expand description

Re-export of TribleSet. A collection of Tribles.

A TribleSet is a collection of Tribles that can be queried and manipulated. It supports efficient set operations like union, intersection, and difference.

The stored Tribles are indexed by the six possible orderings of their fields in corresponding PATCHes.

Clone is extremely cheap and can be used to create a snapshot of the current state of the TribleSet.

Note that the TribleSet does not support an explicit delete/remove operation, as this would conflict with the CRDT semantics of the TribleSet and CALM principles as a whole. It does allow for set subtraction, but that operation is meant to compute the difference between two sets and not to remove elements from the set. A subtle but important distinction.

Fields§

§eav: PATCH<TRIBLE_LEN, EAVOrder, ()>

Entity → Attribute → Value index.

§vea: PATCH<TRIBLE_LEN, VEAOrder, ()>

Value → Entity → Attribute index.

§ave: PATCH<TRIBLE_LEN, AVEOrder, ()>

Attribute → Value → Entity index.

§vae: PATCH<TRIBLE_LEN, VAEOrder, ()>

Value → Attribute → Entity index.

§eva: PATCH<TRIBLE_LEN, EVAOrder, ()>

Entity → Value → Attribute index.

§aev: PATCH<TRIBLE_LEN, AEVOrder, ()>

Attribute → Entity → Value index.

Implementations§

Source§

impl TribleSet

Source

pub fn union(&mut self, other: Self)

Union of two TribleSets.

The other TribleSet is consumed, and this TribleSet is updated in place.

Source

pub fn intersect(&self, other: &Self) -> Self

Returns a new set containing only tribles present in both sets.

Source

pub fn difference(&self, other: &Self) -> Self

Returns a new set containing tribles in self but not in other.

Source

pub fn new() -> TribleSet

Creates an empty set.

Source

pub fn len(&self) -> usize

Returns the number of tribles in the set.

Source

pub fn is_empty(&self) -> bool

Returns true when the set contains no tribles.

Source

pub fn fingerprint(&self) -> TribleSetFingerprint

Returns a fast fingerprint suitable for in-memory caching.

The fingerprint matches TribleSet equality, but it is not stable across process boundaries because PATCH uses a per-process hash key.

Source

pub fn insert(&mut self, trible: &Trible)

Inserts a trible into all six covering indexes.

Source

pub fn contains(&self, trible: &Trible) -> bool

Returns true when the exact trible is present in the set.

Source

pub fn value_in_range<V: ValueSchema>( &self, variable: Variable<V>, min: Value<V>, max: Value<V>, ) -> TribleSetRangeConstraint

Creates a constraint that proposes only values in the byte range [min, max] (inclusive) using the VEA index with infixes_range.

Use with and! alongside a pattern! for efficient range queries:

find!(ts: Value<NsTAIInterval>,
    and!(
        pattern!(&data, [{ ?id @ attr: ?ts }]),
        data.value_in_range(ts, min_ts, max_ts),
    )
)
Source

pub fn iter(&self) -> TribleSetIterator<'_>

Iterates over all tribles in EAV order.

Trait Implementations§

Source§

impl Add<Fragment> for TribleSet

Source§

type Output = TribleSet

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Fragment) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<TribleSet> for Fragment

Source§

type Output = Fragment

The resulting type after applying the + operator.
Source§

fn add(self, rhs: TribleSet) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for TribleSet

Source§

type Output = TribleSet

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<Fragment> for TribleSet

Source§

fn add_assign(&mut self, rhs: Fragment)

Performs the += operation. Read more
Source§

impl AddAssign<TribleSet> for Fragment

Source§

fn add_assign(&mut self, rhs: TribleSet)

Performs the += operation. Read more
Source§

impl AddAssign for TribleSet

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for TribleSet

Source§

fn clone(&self) -> TribleSet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TribleSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TribleSet

Source§

fn default() -> Self

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

impl<U> From<&SuccinctArchive<U>> for TribleSet
where U: Universe,

Source§

fn from(archive: &SuccinctArchive<U>) -> Self

Converts to this type from the input type.
Source§

impl<U> From<&TribleSet> for SuccinctArchive<U>
where U: Universe + Serializable<Error = Error>, <U as Serializable>::Meta: Clone,

Source§

fn from(set: &TribleSet) -> Self

Converts to this type from the input type.
Source§

impl From<&TribleSet> for TribleSetFingerprint

Source§

fn from(set: &TribleSet) -> Self

Converts to this type from the input type.
Source§

impl From<Fragment> for TribleSet

Source§

fn from(value: Fragment) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Trible> for TribleSet

Source§

fn from_iter<I: IntoIterator<Item = Trible>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a> IntoIterator for &'a TribleSet

Source§

type Item = &'a Trible

The type of the elements being iterated over.
Source§

type IntoIter = TribleSetIterator<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq<Checkout> for TribleSet

Source§

fn eq(&self, other: &Checkout) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<TribleSet> for Checkout

Source§

fn eq(&self, other: &TribleSet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for TribleSet

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToBlob<SimpleArchive> for &TribleSet

Source§

fn to_blob(self) -> Blob<SimpleArchive>

Converts this value into a blob.
Source§

impl ToBlob<SimpleArchive> for TribleSet

Source§

fn to_blob(self) -> Blob<SimpleArchive>

Converts this value into a blob.
Source§

impl TriblePattern for TribleSet

Source§

type PatternConstraint<'a> = TribleSetConstraint

The type of the constraint created by the pattern method.
Source§

fn pattern<V: ValueSchema>( &self, e: Variable<GenId>, a: Variable<GenId>, v: Variable<V>, ) -> Self::PatternConstraint<'static>

Create a constraint for a given trible pattern. The method takes three variables, one for each part of the trible. The schemas of the entities and attributes are always GenId, while the value schema can be any type implementing ValueSchema and is specified as a type parameter. Read more
Source§

impl TryFromBlob<SimpleArchive> for TribleSet

Source§

type Error = UnarchiveError

The error type returned when the conversion fails.
Source§

fn try_from_blob(blob: Blob<SimpleArchive>) -> Result<Self, Self::Error>

Attempts to convert a blob into this type.
Source§

impl Eq for TribleSet

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V