Module joiner

Module joiner 

Source
Expand description

Joiner functions for constraint stream joins.

Joiners define matching conditions between entities in different streams (cross-joins) or the same stream (self-joins).

§Self-joins

Use equal() with a single extractor for self-joins:

use solverforge_scoring::stream::joiner::{Joiner, equal};

#[derive(Clone)]
struct Shift { employee_id: usize, start: i64, end: i64 }

// Match shifts with the same employee
let same_employee = equal(|s: &Shift| s.employee_id);
assert!(same_employee.matches(
    &Shift { employee_id: 1, start: 0, end: 8 },
    &Shift { employee_id: 1, start: 8, end: 16 }
));

§Cross-joins

Use equal_bi() for cross-joins between different types:

use solverforge_scoring::stream::joiner::{Joiner, equal_bi};

struct Employee { id: usize }
struct Shift { employee_id: Option<usize> }

let by_id = equal_bi(
    |shift: &Shift| shift.employee_id,
    |emp: &Employee| Some(emp.id)
);

Structs§

AndJoiner
A joiner that combines two joiners with AND semantics.
EqualJoiner
A joiner that matches when extracted values are equal.
FilteringJoiner
A joiner that matches based on a custom predicate.
FnJoiner
A joiner wrapping a closure for testing and simple cases.
GreaterThanJoiner
A joiner that matches when left(a) > right(b).
GreaterThanOrEqualJoiner
A joiner that matches when left(a) >= right(b).
LessThanJoiner
A joiner that matches when left(a) < right(b).
LessThanOrEqualJoiner
A joiner that matches when left(a) <= right(b).
OverlappingJoiner
A joiner that matches when two intervals overlap.

Traits§

Joiner
A joiner defines matching conditions between two entities.

Functions§

equal
Creates a joiner that matches when a property is equal on both sides.
equal_bi
Creates a joiner that matches when extracted values are equal.
filtering
Creates a joiner that matches based on a custom predicate.
greater_than
Creates a joiner that matches when left(a) > right(b).
greater_than_or_equal
Creates a joiner that matches when left(a) >= right(b).
less_than
Creates a joiner that matches when left(a) < right(b).
less_than_or_equal
Creates a joiner that matches when left(a) <= right(b).
overlapping
Creates a joiner that matches when two intervals overlap.