pub struct KeyedSingleton<K, V, Loc, Bound> { /* private fields */ }Implementations§
Source§impl<'a, K, V, L: Location<'a>, B> KeyedSingleton<K, V, L, B>
impl<'a, K, V, L: Location<'a>, B> KeyedSingleton<K, V, L, B>
pub fn map<U, F>(
self,
f: impl IntoQuotedMut<'a, F, L> + Copy,
) -> KeyedSingleton<K, U, L, B>where
F: Fn(V) -> U + 'a,
pub fn filter<F>( self, f: impl IntoQuotedMut<'a, F, L> + Copy, ) -> KeyedSingleton<K, V, L, B>
pub fn filter_map<F, U>( self, f: impl IntoQuotedMut<'a, F, L> + Copy, ) -> KeyedSingleton<K, U, L, B>
pub fn key_count(self) -> Singleton<usize, L, B>
Sourcepub fn ir_node_named(self, name: &str) -> KeyedSingleton<K, V, L, B>
pub fn ir_node_named(self, name: &str) -> KeyedSingleton<K, V, L, B>
An operator which allows you to “name” a HydroNode.
This is only used for testing, to correlate certain HydroNodes with IDs.
Source§impl<'a, K: Hash + Eq, V, L: Location<'a>> KeyedSingleton<K, V, Tick<L>, Bounded>
impl<'a, K: Hash + Eq, V, L: Location<'a>> KeyedSingleton<K, V, Tick<L>, Bounded>
Sourcepub fn get(
self,
key: Singleton<K, Tick<L>, Bounded>,
) -> Optional<V, Tick<L>, Bounded>
pub fn get( self, key: Singleton<K, Tick<L>, Bounded>, ) -> Optional<V, Tick<L>, Bounded>
Gets the value associated with a specific key from the keyed singleton.
§Example
let tick = process.tick();
let keyed_data = process
.source_iter(q!(vec![(1, 2), (2, 3)]))
.into_keyed()
.batch(&tick, nondet!(/** test */))
.fold(q!(|| 0), q!(|acc, x| *acc = x));
let key = tick.singleton(q!(1));
keyed_data.get(key).all_ticks()
// 2Sourcepub fn get_many<O2, R2, V2>(
self,
with: KeyedStream<K, V2, Tick<L>, Bounded, O2, R2>,
) -> KeyedStream<K, (V, V2), Tick<L>, Bounded, NoOrder, R2>
pub fn get_many<O2, R2, V2>( self, with: KeyedStream<K, V2, Tick<L>, Bounded, O2, R2>, ) -> KeyedStream<K, (V, V2), Tick<L>, Bounded, NoOrder, R2>
Given a keyed stream of lookup requests, where the key is the lookup and the value is some additional metadata, emits a keyed stream of lookup results where the key is the same as before, but the value is a tuple of the lookup result and the metadata of the request.
§Example
let tick = process.tick();
let keyed_data = process
.source_iter(q!(vec![(1, 10), (2, 20)]))
.into_keyed()
.batch(&tick, nondet!(/** test */))
.fold(q!(|| 0), q!(|acc, x| *acc = x));
let other_data = process
.source_iter(q!(vec![(1, 100), (2, 200), (1, 101)]))
.into_keyed()
.batch(&tick, nondet!(/** test */));
keyed_data.get_many(other_data).entries().all_ticks()
// { 1: [(10, 100), (10, 101)], 2: [(20, 200)] } in any orderpub fn latest(self) -> KeyedSingleton<K, V, L, Unbounded>
Source§impl<'a, K, V, L, B> KeyedSingleton<K, V, L, B>
impl<'a, K, V, L, B> KeyedSingleton<K, V, L, B>
pub fn atomic(self, tick: &Tick<L>) -> KeyedSingleton<K, V, Atomic<L>, B>
Sourcepub fn snapshot(
self,
tick: &Tick<L>,
nondet: NonDet,
) -> KeyedSingleton<K, V, Tick<L>, Bounded>
pub fn snapshot( self, tick: &Tick<L>, nondet: NonDet, ) -> KeyedSingleton<K, V, Tick<L>, Bounded>
Given a tick, returns a keyed singleton with a entries consisting of keys with snapshots of the value singleton.
§Non-Determinism
Because this picks a snapshot of each singleton whose value is continuously changing, the output singleton has a non-deterministic value since each snapshot can be at an arbitrary point in time.
Source§impl<'a, K, V, L, B> KeyedSingleton<K, V, Atomic<L>, B>
impl<'a, K, V, L, B> KeyedSingleton<K, V, Atomic<L>, B>
Sourcepub fn snapshot(self, _nondet: NonDet) -> KeyedSingleton<K, V, Tick<L>, Bounded>
pub fn snapshot(self, _nondet: NonDet) -> KeyedSingleton<K, V, Tick<L>, Bounded>
Returns a keyed singleton with a entries consisting of keys with snapshots of the value singleton being atomically processed.
§Non-Determinism
Because this picks a snapshot of each singleton whose value is continuously changing, each output singleton has a non-deterministic value since each snapshot can be at an arbitrary point in time.
Trait Implementations§
Source§impl<'a, K: Clone, V: Clone, Loc: Location<'a>, Bound> Clone for KeyedSingleton<K, V, Loc, Bound>
impl<'a, K: Clone, V: Clone, Loc: Location<'a>, Bound> Clone for KeyedSingleton<K, V, Loc, Bound>
Source§impl<'a, K, V, L, B> CycleCollection<'a, ForwardRefMarker> for KeyedSingleton<K, V, L, B>
impl<'a, K, V, L, B> CycleCollection<'a, ForwardRefMarker> for KeyedSingleton<K, V, L, B>
Source§impl<'a, K, V, L, B> CycleComplete<'a, ForwardRefMarker> for KeyedSingleton<K, V, L, B>
impl<'a, K, V, L, B> CycleComplete<'a, ForwardRefMarker> for KeyedSingleton<K, V, L, B>
fn complete(self, ident: Ident, expected_location: LocationId)
Auto Trait Implementations§
impl<K, V, Loc, Bound> !Freeze for KeyedSingleton<K, V, Loc, Bound>
impl<K, V, Loc, Bound> !RefUnwindSafe for KeyedSingleton<K, V, Loc, Bound>
impl<K, V, Loc, Bound> !Send for KeyedSingleton<K, V, Loc, Bound>
impl<K, V, Loc, Bound> !Sync for KeyedSingleton<K, V, Loc, Bound>
impl<K, V, Loc, Bound> Unpin for KeyedSingleton<K, V, Loc, Bound>
impl<K, V, Loc, Bound> !UnwindSafe for KeyedSingleton<K, V, Loc, Bound>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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