pub struct GroupedConstraintStream<S, A, K, E, Fi, KF, C, V, R, Acc, Sc>where
Sc: Score,{ /* private fields */ }Expand description
Zero-erasure constraint stream over grouped entities.
GroupedConstraintStream is created by UniConstraintStream::group_by()
and operates on (key, collector_result) tuples.
All type parameters are concrete - no trait objects, no Arc allocations.
Implementations§
Source§impl<S, A, K, E, Fi, KF, C, V, R, Acc, Sc> GroupedConstraintStream<S, A, K, E, Fi, KF, C, V, R, Acc, Sc>where
S: Send + Sync + 'static,
A: Clone + Send + Sync + 'static,
K: Clone + Eq + Hash + Send + Sync + 'static,
E: CollectionExtract<S, Item = A>,
Fi: UniFilter<S, A>,
KF: Fn(&A) -> K + Send + Sync,
C: for<'i> Collector<&'i A, Value = V, Result = R, Accumulator = Acc> + Send + Sync + 'static,
V: Send + Sync + 'static,
R: Send + Sync + 'static,
Acc: Accumulator<V, R> + Send + Sync + 'static,
Sc: Score + 'static,
impl<S, A, K, E, Fi, KF, C, V, R, Acc, Sc> GroupedConstraintStream<S, A, K, E, Fi, KF, C, V, R, Acc, Sc>where
S: Send + Sync + 'static,
A: Clone + Send + Sync + 'static,
K: Clone + Eq + Hash + Send + Sync + 'static,
E: CollectionExtract<S, Item = A>,
Fi: UniFilter<S, A>,
KF: Fn(&A) -> K + Send + Sync,
C: for<'i> Collector<&'i A, Value = V, Result = R, Accumulator = Acc> + Send + Sync + 'static,
V: Send + Sync + 'static,
R: Send + Sync + 'static,
Acc: Accumulator<V, R> + Send + Sync + 'static,
Sc: Score + 'static,
Sourcepub fn penalize<W>(
self,
weight: W,
) -> GroupedConstraintBuilder<S, A, K, E, Fi, KF, C, V, R, Acc, impl Fn(&K, &R) -> Sc + Send + Sync, Sc>
pub fn penalize<W>( self, weight: W, ) -> GroupedConstraintBuilder<S, A, K, E, Fi, KF, C, V, R, Acc, impl Fn(&K, &R) -> Sc + Send + Sync, Sc>
Penalizes each group by weight.
weight is a fixed score, or a closure over the matched (&key, &result) returning one.
A fixed weight with a non-zero hard level marks the constraint hard; closures
are soft unless wrapped in hard_weight.
Sourcepub fn reward<W>(
self,
weight: W,
) -> GroupedConstraintBuilder<S, A, K, E, Fi, KF, C, V, R, Acc, impl Fn(&K, &R) -> Sc + Send + Sync, Sc>
pub fn reward<W>( self, weight: W, ) -> GroupedConstraintBuilder<S, A, K, E, Fi, KF, C, V, R, Acc, impl Fn(&K, &R) -> Sc + Send + Sync, Sc>
Rewards each group by weight.
weight is a fixed score, or a closure over the matched (&key, &result) returning one.
A fixed weight with a non-zero hard level marks the constraint hard; closures
are soft unless wrapped in hard_weight.
Sourcepub fn complement<B, EB, KB, D>(
self,
extractor_b: EB,
key_b: KB,
default_fn: D,
) -> ComplementedConstraintStream<S, A, B, K, E, EB, impl Fn(&A) -> Option<K> + Send + Sync, KB, C, V, R, Acc, D, Sc>
pub fn complement<B, EB, KB, D>( self, extractor_b: EB, key_b: KB, default_fn: D, ) -> ComplementedConstraintStream<S, A, B, K, E, EB, impl Fn(&A) -> Option<K> + Send + Sync, KB, C, V, R, Acc, D, Sc>
Adds complement entities with default values for missing keys.
Sourcepub fn join<B, EB, KB>(
self,
target: (EB, KB),
) -> GroupedJoinedStream<S, A, B, K, E, EB, Fi, KF, C, V, R, Acc, KB, Sc>
pub fn join<B, EB, KB>( self, target: (EB, KB), ) -> GroupedJoinedStream<S, A, B, K, E, EB, Fi, KF, C, V, R, Acc, KB, Sc>
Relates the grouped result to a second collection by the group key.
The result is a join of the group (key + aggregate) with every entity of the second collection whose key equals the group key. Weighting sees the group key, its aggregated result, and the matched entity.
Sourcepub fn complement_with_key<B, EB, KA2, KB, D>(
self,
extractor_b: EB,
key_a: KA2,
key_b: KB,
default_fn: D,
) -> ComplementedConstraintStream<S, A, B, K, E, EB, KA2, KB, C, V, R, Acc, D, Sc>
pub fn complement_with_key<B, EB, KA2, KB, D>( self, extractor_b: EB, key_a: KA2, key_b: KB, default_fn: D, ) -> ComplementedConstraintStream<S, A, B, K, E, EB, KA2, KB, C, V, R, Acc, D, Sc>
Adds complement entities with a custom key function for filtering.