Relation

Struct Relation 

Source
pub struct Relation<C: Op_> { /* private fields */ }

Implementations§

Source§

impl<C: Op> Relation<C>

Source

pub fn minus( self, other: Relation<impl Op<D = C::D>>, ) -> Relation<impl Op<D = C::D>>

Source§

impl<C: Op_> Relation<C>

Source

pub fn dynamic<'a>(self) -> Relation<Dynamic<'a, C::T>>
where C: 'a,

Simplifies the inferred type-signature of a relation at the cost of requiring dynamic dispatch at runtime.

Try inserting this in the middle of a big relation if the compiler is running slowly or using up too much memory.

Source§

impl<'a, K: Clone + Eq + Hash + 'a, V: Clone + Eq + Hash + 'a, C: Op<D = (K, V)> + 'a> Relation<C>

Source

pub fn first_occurences<I>( self, context: &mut CreationContext<'a, I>, ) -> Relation<impl Op<D = (K, V)>>

Source§

impl<K: Clone + Eq + Hash, V: Clone + Eq + Hash, C: Op<D = (K, V)>> Relation<C>

Source

pub fn semijoin( self, other: Relation<impl Op<D = K>>, ) -> Relation<impl Op<D = (K, V)>>

Source

pub fn join_values<V2: Clone + Eq + Hash>( self, other: Relation<impl Op<D = (K, V2)>>, ) -> Relation<impl Op<D = (V, V2)>>

Source

pub fn left_join<V2: Clone + Eq + Hash>( self, other: Relation<impl Op<D = (K, V2)>>, ) -> Relation<impl Op<D = (K, V, Option<V2>)>>

Source§

impl<C: Op> Relation<C>
where C::D: Clone + Eq + Hash,

Source

pub fn intersection( self, other: Relation<impl Op<D = C::D>>, ) -> Relation<impl Op<D = C::D>>

Source

pub fn set_minus( self, other: Relation<impl Op<D = C::D>>, ) -> Relation<impl Op<D = C::D>>

Source§

impl<C: Op_> Relation<C>

Source

pub fn map_<Y, F: Fn(C::T) -> Y>(self, f: F) -> Relation<impl Op_<T = Y>>

Source

pub fn debug(self, name: &'static str) -> Relation<impl Op_<T = C::T>>
where C::T: Debug,

Source§

impl<C: Op> Relation<C>

Source

pub fn flat_map<I: IntoIterator>( self, f: impl Fn(C::D) -> I, ) -> Relation<impl Op<D = I::Item>>

Source

pub fn flatten(self) -> Relation<impl Op<D = <C::D as IntoIterator>::Item>>
where C::D: IntoIterator,

Source

pub fn map<Y>(self, f: impl Fn(C::D) -> Y) -> Relation<impl Op<D = Y>>

Source

pub fn map_h<Y>(self, f: impl Fn(C::D) -> Y) -> Relation<impl Op<D = Y>>

Source

pub fn filter(self, f: impl Fn(&C::D) -> bool) -> Relation<impl Op<D = C::D>>

Source

pub fn map_counts( self, f: impl Fn(isize) -> isize, ) -> Relation<impl Op<D = C::D>>

Source

pub fn negate(self) -> Relation<impl Op<D = C::D>>

Source§

impl<A, B, C: Op<D = (A, B)>> Relation<C>

Source

pub fn fsts(self) -> Relation<impl Op<D = A>>

Source

pub fn snds(self) -> Relation<impl Op<D = B>>

Source

pub fn swaps(self) -> Relation<impl Op<D = (B, A)>>

Source§

impl<C: Op> Relation<C>

Source

pub fn into_output(self, context: &CreationContext<'_>) -> Output<C::D, C>
where C::D: Eq + Hash,

Source§

impl<K, V, C: Op<D = (K, V)>> Relation<C>

Source

pub fn into_kv_output( self, context: &CreationContext<'_>, ) -> Output<(K, V), C, HashMap<K, HashMap<V, isize>>>
where K: Eq + Hash, V: Eq + Hash,

Source

pub fn into_extrema_output( self, context: &CreationContext<'_>, ) -> Output<(K, V), C, ExtremaMap<K, V>>
where K: Ord, V: Eq + Hash,

Source§

impl<C: Op> Relation<C>
where C::D: Clone + Eq + Hash,

Source

pub fn counts( self, ) -> Relation<impl IsReduce<T = ((C::D, isize), isize), OM = HashMap<C::D, isize>>>

Source

pub fn distinct(self) -> Relation<impl Op<D = C::D>>

Source§

impl<C: Op<D = (K, V)>, K: Clone + Eq + Hash, V> Relation<C>

Source

pub fn reduce_<M: CountMap<V> + Observable, Y: Clone + Eq, F: Fn(&K, &M) -> Y>( self, f: F, ) -> Relation<Reduce<K, V, C, M, Y, HashMap<K, Y>, F>>

Source

pub fn reduce<Y: Clone + Eq>( self, f: impl Fn(&K, &HashMap<V, isize>) -> Y, ) -> Relation<impl IsReduce<T = ((K, Y), isize), OM = HashMap<K, Y>>>
where V: Eq + Hash,

Source

pub fn group_min( self, ) -> Relation<impl IsReduce<T = ((K, V), isize), OM = HashMap<K, V>>>
where V: Clone + Ord,

Source

pub fn group_max( self, ) -> Relation<impl IsReduce<T = ((K, V), isize), OM = HashMap<K, V>>>
where V: Clone + Ord,

Source§

impl<C: Op<D = (L, R)>, L, R> Relation<C>

Source

pub fn split(self) -> (Relation<impl Op<D = L>>, Relation<impl Op<D = R>>)

Splits a collection of 2-tuples into a 2-tuple of collections.

Example:

   use standing_relations::CreationContext;
   use std::{collections::HashMap, iter::FromIterator};

   let mut context = CreationContext::new();
   let (mut foo_input, foo) = context.new_input::<usize>();
   let (evens, odds) = foo.map(|x| (x * 2, x * 2 + 1)).split();
   let evens = evens.into_output(&context);
   let odds = odds.into_output(&context);
    
   let mut context = context.begin();
   foo_input.add_all(&context, 0 .. 2);
   context.commit();
   assert_eq!(&*evens.get(&context), &HashMap::from_iter(vec![(0,1),(2,1)]));
   assert_eq!(&*odds.get(&context), &HashMap::from_iter(vec![(1,1),(3,1)]));
Source§

impl<C: Op> Relation<C>
where C::D: Clone,

Source

pub fn collect<'a>(self) -> Collection<'a, C::D>
where C: 'a,

Source

pub fn t<D: Is<Myself = C::D>>(self) -> Self

No-op which nails down the expected item type.

The compiler will complain if the provided type is wrong. This helps you spot type errors where they occur rather than downstream.

Example:

   use standing_relations::CreationContext;
   use std::{collections::HashMap, iter::FromIterator};

   let mut context = CreationContext::new();
   let (_foo_input, foo) = context.new_input::<(char, isize)>();
   let (_bar_input, bar) = context.new_input::<char>();
   let foobar =
       foo.join(bar.counts()).flat_map(|(k,x,y)| if x < y {Some((k,x))} else {None});
   let foobar = foobar.t::<(char, isize)>();

Note that if instead of flat_map, we had accidentally used map, the compiler would complain because foobar would have item type Option<(char, isize)> where we expect (char, isize).

Source§

impl<C1: Op_> Relation<C1>

Source

pub fn concat<C2: Op_<T = C1::T>>( self, other: Relation<C2>, ) -> Relation<Concat<C1, C2>>

Source§

impl<C: Op_<T = (D, isize)>, D: Eq + Hash> Relation<C>

Source§

impl<C: Op_> Relation<C>

Source

pub fn dynamic_shown<'a>(self) -> Relation<Dynamic<'a, C::T>>
where C: 'a,

Source§

impl<K: Clone + Eq + Hash, V1: Clone + Eq + Hash, C1: Op<D = (K, V1)>> Relation<C1>

Source

pub fn join<V2: Clone + Eq + Hash, C2: Op<D = (K, V2)>>( self, other: Relation<C2>, ) -> Relation<Join<K, V1, V2, C1, C2>>

Source

pub fn antijoin<C2: Op<D = K>>( self, other: Relation<C2>, ) -> Relation<AntiJoin<K, V1, C1, C2>>

Retains only those keys which have count 0 in the argument relation.

Source§

impl<C: Op_> Relation<C>

Source

pub fn flat_map_<I: IntoIterator, F: Fn(C::T) -> I>( self, f: F, ) -> Relation<FlatMap<C, I, F>>

Source§

impl<C: Op<D = (K, X)>, K: Clone + Eq + Hash, X> Relation<C>

Source

pub fn reduce_with_output_<M: CountMap<X> + Observable, OM: OutputMap<K, Y> + Default, Y: Clone + Eq, F: Fn(&K, &M) -> Y>( self, f: F, ) -> Relation<Reduce<K, X, C, M, Y, OM, F>>

Source§

impl<C: IsReduce> Relation<C>

Source

pub fn probe(self, context: &CreationContext<'_>) -> ReduceProbe<C>

Source§

impl<C: Op_> Relation<C>

Source

pub fn save(self) -> Saved<C>
where C::T: Clone,

Source§

impl<C: Op_<T = (L, R)>, L, R> Relation<C>

Source

pub fn split_( self, ) -> (Relation<Split<L, C, L, R>>, Relation<Split<R, C, L, R>>)

Source§

impl<X: Clone + Eq + Hash, Y: Clone + Eq + Hash, C1: Op<D = (X, Y)>> Relation<C1>

Source

pub fn triangles<Z: Clone + Eq + Hash, C2: Op<D = (X, Z)>, C3: Op<D = (Y, Z)>>( self, rel2: Relation<C2>, rel3: Relation<C3>, ) -> Relation<Triangles<X, Y, Z, C1, C2, C3>>

Source§

impl<C: Op> Relation<C>

Source

pub fn into_output_<M: CountMap<C::D>>( self, context: &CreationContext<'_>, ) -> Output<C::D, C, M>

Source§

impl<C: Op_> Relation<C>

Source

pub fn tracking_index(&self) -> TrackingIndex

Source

pub fn named(self, name: &str) -> Self

Source

pub fn type_named(self, type_name: &str) -> Self

Source

pub fn hidden(self) -> Self

Trait Implementations§

Source§

impl<C: Op_> Clone for Relation<Save<C>>
where C::T: Clone,

Source§

fn clone(&self) -> Self

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

Auto Trait Implementations§

§

impl<C> Freeze for Relation<C>
where C: Freeze,

§

impl<C> !RefUnwindSafe for Relation<C>

§

impl<C> !Send for Relation<C>

§

impl<C> !Sync for Relation<C>

§

impl<C> Unpin for Relation<C>
where C: Unpin,

§

impl<C> !UnwindSafe for Relation<C>

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

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.