pub struct Bi<S, A, B, P, EA, EB, F, Sc>where
Sc: Score,{ /* private fields */ }Expand description
Zero-erasure constraint stream over cross-entity pairs.
Bi joins entities from collection A with collection B, accumulates
filters on joined pairs, and finalizes into an operator terminal via
penalize() or reward(). P is the compiled first-relationship plan:
BiUnaryPlan for a keyed join, FilteringJoiner for a predicate join.
The finalize, join, and filter paths are generic over P; grouping,
projection, and flattening are specialized to BiUnaryPlan, where a
unary key pair exists to rederive.
Implementations§
Source§impl<S, A, B, K, KA, KB, EA, EB, Sc> Bi<S, A, B, BiUnaryPlan<K, KA, KB>, EA, EB, TrueFilter, Sc>
impl<S, A, B, K, KA, KB, EA, EB, Sc> Bi<S, A, B, BiUnaryPlan<K, KA, KB>, EA, EB, TrueFilter, Sc>
Source§impl<S, A, B, K, KA, KB, EA, EB, F, Sc> Bi<S, A, B, BiUnaryPlan<K, KA, KB>, EA, EB, F, Sc>
impl<S, A, B, K, KA, KB, EA, EB, F, Sc> Bi<S, A, B, BiUnaryPlan<K, KA, KB>, EA, EB, F, Sc>
Sourcepub fn new_with_filter(
extractor_a: EA,
extractor_b: EB,
key_a: KA,
key_b: KB,
filter: F,
) -> Self
pub fn new_with_filter( extractor_a: EA, extractor_b: EB, key_a: KA, key_b: KB, filter: F, ) -> Self
Builds a keyed cross-bi stream with an initial joined-pair filter.
Source§impl<S, A, B, P, EA, EB, F, Sc> Bi<S, A, B, P, EA, EB, F, Sc>where
S: Send + Sync + 'static,
A: Send + Sync + 'static,
B: Send + Sync + 'static,
EA: CollectionExtract<S, Item = A>,
EB: CollectionExtract<S, Item = B>,
F: BiFilter<S, A, B>,
Sc: Score + 'static,
impl<S, A, B, P, EA, EB, F, Sc> Bi<S, A, B, P, EA, EB, F, Sc>where
S: Send + Sync + 'static,
A: Send + Sync + 'static,
B: Send + Sync + 'static,
EA: CollectionExtract<S, Item = A>,
EB: CollectionExtract<S, Item = B>,
F: BiFilter<S, A, B>,
Sc: Score + 'static,
Sourcepub fn filter<Q>(
self,
predicate: Q,
) -> Bi<S, A, B, P, EA, EB, AndBiFilter<F, FnBiFilter<impl Fn(&S, &A, &B, usize, usize) -> bool + Send + Sync>>, Sc>
pub fn filter<Q>( self, predicate: Q, ) -> Bi<S, A, B, P, EA, EB, AndBiFilter<F, FnBiFilter<impl Fn(&S, &A, &B, usize, usize) -> bool + Send + Sync>>, Sc>
Adds a filter predicate to the stream.
Sourcepub fn join<C, EC, P2>(
self,
target: (EC, P2),
) -> Tri<S, A, B, C, EA, EB, EC, P, P2, TriAsBiFilter<F, A, B>, Sc>where
C: Send + Sync + 'static,
EC: CollectionExtract<S, Item = C> + 'static,
P: CompileCondition + 'static,
for<'a> P::Plan: ExecutablePlan<Leaf<'a, A>, Leaf<'a, B>> + IndexedPlan<Indexes: Send + Sync>,
P2: CompileCondition + 'static,
for<'a> P2::Plan: IndexedPlan + ExecutablePlan<Pair<Leaf<'a, A>, Leaf<'a, B>>, Leaf<'a, C>>,
EA: 'static,
EB: 'static,
pub fn join<C, EC, P2>(
self,
target: (EC, P2),
) -> Tri<S, A, B, C, EA, EB, EC, P, P2, TriAsBiFilter<F, A, B>, Sc>where
C: Send + Sync + 'static,
EC: CollectionExtract<S, Item = C> + 'static,
P: CompileCondition + 'static,
for<'a> P::Plan: ExecutablePlan<Leaf<'a, A>, Leaf<'a, B>> + IndexedPlan<Indexes: Send + Sync>,
P2: CompileCondition + 'static,
for<'a> P2::Plan: IndexedPlan + ExecutablePlan<Pair<Leaf<'a, A>, Leaf<'a, B>>, Leaf<'a, C>>,
EA: 'static,
EB: 'static,
Extends the joined (A, B) pairs with a third source C.
One uniform .join(): the target tuple’s condition type chooses
execution through CompileCondition. A row-aware joiner (equal_on)
relates the whole borrowed (A, B) row to C on its own key domain; a
unary joiner (equal_bi) is adapted onto the row so the same
independent-domain tree executes it. Shared-key retention is not
involved at any depth.
§Key shapes
This is the SECOND or later join of a chain, so its keys are view keys, not entity keys:
- left key — called on the whole borrowed row so far:
|row: &Pair<Leaf<'_, A>, Leaf<'_, B>>| row.left.entity.key(any earlier binding is reachable throughrow.left/row.right) - right key — called on a
Leafview of the new entity:|c: &Leaf<'_, C>| c.entity.key
equal_bi(|a: &A| ..., |b: &B| ...) does NOT typecheck here (error E0631
“expected fn(&’b Pair<Leaf<’a, A>, Leaf<’a, B>>)”) — the left row of a
later join is the join result, and an ambiguous entity key cannot say
WHICH side of a self-join it reads. Use equal_on.
Source§impl<S, A, B, K, KA, KB, EA, EB, F, Sc> Bi<S, A, B, BiUnaryPlan<K, KA, KB>, EA, EB, F, Sc>where
S: Send + Sync + 'static,
A: Send + Sync + 'static,
B: Send + Sync + 'static,
K: Eq + Hash + Clone + Send + Sync + 'static,
EA: CollectionExtract<S, Item = A>,
EB: CollectionExtract<S, Item = B>,
KA: Fn(&A) -> K + Send + Sync,
KB: Fn(&B) -> K + Send + Sync,
F: BiFilter<S, A, B>,
Sc: Score + 'static,
impl<S, A, B, K, KA, KB, EA, EB, F, Sc> Bi<S, A, B, BiUnaryPlan<K, KA, KB>, EA, EB, F, Sc>where
S: Send + Sync + 'static,
A: Send + Sync + 'static,
B: Send + Sync + 'static,
K: Eq + Hash + Clone + Send + Sync + 'static,
EA: CollectionExtract<S, Item = A>,
EB: CollectionExtract<S, Item = B>,
KA: Fn(&A) -> K + Send + Sync,
KB: Fn(&B) -> K + Send + Sync,
F: BiFilter<S, A, B>,
Sc: Score + 'static,
Sourcepub fn flatten_last<C, CK, Flatten, CKeyFn, ALookup>(
self,
flatten: Flatten,
c_key_fn: CKeyFn,
a_lookup_fn: ALookup,
) -> FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, TrueFilter, Sc>
pub fn flatten_last<C, CK, Flatten, CKeyFn, ALookup>( self, flatten: Flatten, c_key_fn: CKeyFn, a_lookup_fn: ALookup, ) -> FlattenedBiConstraintStream<S, A, B, C, K, CK, EA, EB, KA, KB, Flatten, CKeyFn, ALookup, TrueFilter, Sc>
Expands items from entity B into separate (A, C) pairs with O(1) lookup.
Sourcepub fn group_by<GK, GF, C, V, R, Acc>(
self,
group_key_fn: GF,
collector: C,
) -> Grouped<S, A, B, K, GK, EA, EB, KA, KB, F, GF, C, V, R, Acc, Sc>
pub fn group_by<GK, GF, C, V, R, Acc>( self, group_key_fn: GF, collector: C, ) -> Grouped<S, A, B, K, GK, EA, EB, KA, KB, F, GF, C, V, R, Acc, Sc>
Groups joined pairs by group_key_fn(a, b), aggregating each group with
collector.
Sourcepub fn project<Out, Proj>(
self,
project: Proj,
) -> Stream<S, Out, JoinedSource<S, A, B, K, EA, EB, KA, KB, F, Proj, Out>, TrueFilter, Sc>
pub fn project<Out, Proj>( self, project: Proj, ) -> Stream<S, Out, JoinedSource<S, A, B, K, EA, EB, KA, KB, F, Proj, Out>, TrueFilter, Sc>
Projects each joined pair to an Out row with project, continuing as a
projected stream.
Source§impl<S, A, B, P, EA, EB, F, Sc> Bi<S, A, B, P, EA, EB, F, Sc>where
S: Send + Sync + 'static,
A: Send + Sync + 'static,
B: Send + Sync + 'static,
P: CompileCondition + 'static,
for<'a> P::Plan: ExecutablePlan<Leaf<'a, A>, Leaf<'a, B>> + IndexedPlan<Indexes: Send + Sync>,
EA: CollectionExtract<S, Item = A>,
EB: CollectionExtract<S, Item = B>,
F: BiFilter<S, A, B>,
Sc: Score + 'static,
impl<S, A, B, P, EA, EB, F, Sc> Bi<S, A, B, P, EA, EB, F, Sc>where
S: Send + Sync + 'static,
A: Send + Sync + 'static,
B: Send + Sync + 'static,
P: CompileCondition + 'static,
for<'a> P::Plan: ExecutablePlan<Leaf<'a, A>, Leaf<'a, B>> + IndexedPlan<Indexes: Send + Sync>,
EA: CollectionExtract<S, Item = A>,
EB: CollectionExtract<S, Item = B>,
F: BiFilter<S, A, B>,
Sc: Score + 'static,
Sourcepub fn penalize<W>(
self,
weight: W,
) -> Builder<S, A, B, P, EA, EB, F, impl Fn(&A, &B) -> Sc + Send + Sync, Sc>
pub fn penalize<W>( self, weight: W, ) -> Builder<S, A, B, P, EA, EB, F, impl Fn(&A, &B) -> Sc + Send + Sync, Sc>
Penalizes each match by weight.
weight is a fixed score, or a closure over the matched (&A, &B) pair 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,
) -> Builder<S, A, B, P, EA, EB, F, impl Fn(&A, &B) -> Sc + Send + Sync, Sc>
pub fn reward<W>( self, weight: W, ) -> Builder<S, A, B, P, EA, EB, F, impl Fn(&A, &B) -> Sc + Send + Sync, Sc>
Rewards each match by weight.
weight is a fixed score, or a closure over the matched (&A, &B) pair returning one.
A fixed weight with a non-zero hard level marks the constraint hard; closures
are soft unless wrapped in hard_weight.