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.
- Equal
Joiner - A joiner that matches when extracted values are equal.
- Filtering
Joiner - A joiner that matches based on a custom predicate.
- FnJoiner
- A joiner wrapping a closure for testing and simple cases.
- Greater
Than Joiner - A joiner that matches when
left(a) > right(b). - Greater
Than OrEqual Joiner - A joiner that matches when
left(a) >= right(b). - Less
Than Joiner - A joiner that matches when
left(a) < right(b). - Less
Than OrEqual Joiner - A joiner that matches when
left(a) <= right(b). - Overlapping
Joiner - 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.