Skip to main content

Bi

Struct Bi 

Source
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>
where S: Send + Sync + 'static, A: Clone + Send + Sync + 'static, B: Clone + Send + Sync + 'static, K: Eq + Hash + Clone + Send + Sync, EA: CollectionExtract<S, Item = A>, EB: CollectionExtract<S, Item = B>, KA: Fn(&A) -> K + Send + Sync, KB: Fn(&B) -> K + Send + Sync, Sc: Score + 'static,

Source

pub fn new(extractor_a: EA, extractor_b: EB, key_a: KA, key_b: KB) -> Self

Creates a keyed cross join pairing A and B entities whose keys key_a(a) and key_b(b) are equal.

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: Clone + Send + Sync + 'static, B: Clone + Send + Sync + 'static, K: Eq + Hash + Clone + Send + Sync, 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,

Source

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: Clone + Send + Sync + 'static, B: Clone + Send + Sync + 'static, EA: CollectionExtract<S, Item = A>, EB: CollectionExtract<S, Item = B>, F: BiFilter<S, A, B>, Sc: Score + 'static,

Source

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>
where Q: Fn(&A, &B) -> bool + Send + Sync,

Adds a filter predicate to the stream.

Source

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: Clone + 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 through row.left / row.right)
  • right key — called on a Leaf view 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: Clone + Send + Sync + 'static, B: Clone + 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,

Source

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>
where C: Clone + Send + Sync + 'static, CK: Eq + Hash + Clone + Send + Sync, Flatten: Fn(&B) -> &[C] + Send + Sync, CKeyFn: Fn(&C) -> CK + Send + Sync, ALookup: Fn(&A) -> CK + Send + Sync,

Expands items from entity B into separate (A, C) pairs with O(1) lookup.

Source

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>
where GK: Eq + Hash + Clone + Send + Sync + 'static, GF: Fn(&A, &B) -> GK + Send + Sync, C: for<'i> Collector<(&'i A, &'i B), Value = V, Result = R, Accumulator = Acc> + Send + Sync + 'static, V: Send + Sync + 'static, R: Send + Sync + 'static, Acc: Accumulator<V, R> + Send + Sync + 'static,

Groups joined pairs by group_key_fn(a, b), aggregating each group with collector.

Source

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>
where Out: Send + Sync + 'static, Proj: Fn(&A, &B) -> Out + Send + Sync + 'static,

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: Clone + Send + Sync + 'static, B: Clone + 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,

Source

pub fn penalize<W>( self, weight: W, ) -> Builder<S, A, B, P, EA, EB, F, impl Fn(&A, &B) -> Sc + Send + Sync, Sc>
where W: for<'w> ConstraintWeight<(&'w A, &'w B), Sc> + Send + Sync,

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.

Source

pub fn reward<W>( self, weight: W, ) -> Builder<S, A, B, P, EA, EB, F, impl Fn(&A, &B) -> Sc + Send + Sync, Sc>
where W: for<'w> ConstraintWeight<(&'w A, &'w B), Sc> + Send + Sync,

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.

Trait Implementations§

Source§

impl<S, A, B, P, EA, EB, F, Sc: Score> Debug for Bi<S, A, B, P, EA, EB, F, Sc>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, A, B, P, EA, EB, F, Sc> Forget for Bi<S, A, B, P, EA, EB, F, Sc>

§

impl<S, A, B, P, EA, EB, F, Sc> Freeze for Bi<S, A, B, P, EA, EB, F, Sc>
where EA: Freeze, EB: Freeze, P: Freeze, F: Freeze, PhantomData<(fn() -> S, fn() -> A, fn() -> B, fn() -> Sc)>: Freeze,

§

impl<S, A, B, P, EA, EB, F, Sc> Move for Bi<S, A, B, P, EA, EB, F, Sc>

§

impl<S, A, B, P, EA, EB, F, Sc> RefUnwindSafe for Bi<S, A, B, P, EA, EB, F, Sc>
where EA: RefUnwindSafe, EB: RefUnwindSafe, P: RefUnwindSafe, F: RefUnwindSafe, PhantomData<(fn() -> S, fn() -> A, fn() -> B, fn() -> Sc)>: RefUnwindSafe,

§

impl<S, A, B, P, EA, EB, F, Sc> Send for Bi<S, A, B, P, EA, EB, F, Sc>
where EA: Send, EB: Send, P: Send, F: Send, PhantomData<(fn() -> S, fn() -> A, fn() -> B, fn() -> Sc)>: Send,

§

impl<S, A, B, P, EA, EB, F, Sc> Sync for Bi<S, A, B, P, EA, EB, F, Sc>
where EA: Sync, EB: Sync, P: Sync, F: Sync, PhantomData<(fn() -> S, fn() -> A, fn() -> B, fn() -> Sc)>: Sync,

§

impl<S, A, B, P, EA, EB, F, Sc> Unpin for Bi<S, A, B, P, EA, EB, F, Sc>
where EA: Unpin, EB: Unpin, P: Unpin, F: Unpin, PhantomData<(fn() -> S, fn() -> A, fn() -> B, fn() -> Sc)>: Unpin,

§

impl<S, A, B, P, EA, EB, F, Sc> UnsafeUnpin for Bi<S, A, B, P, EA, EB, F, Sc>
where EA: UnsafeUnpin, EB: UnsafeUnpin, P: UnsafeUnpin, F: UnsafeUnpin, PhantomData<(fn() -> S, fn() -> A, fn() -> B, fn() -> Sc)>: UnsafeUnpin,

§

impl<S, A, B, P, EA, EB, F, Sc> UnwindSafe for Bi<S, A, B, P, EA, EB, F, Sc>
where EA: UnwindSafe, EB: UnwindSafe, P: UnwindSafe, F: UnwindSafe, PhantomData<(fn() -> S, fn() -> A, fn() -> B, fn() -> Sc)>: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.