Variable.fromJoin

Adds tuples that result from joining input1 and input2.

Examples

This example starts a collection with the pairs (x, x+1) and (x+1, x) for x in 0 .. 10. It then adds pairs (y, z) for which (x, y) and (x, z) are present. Because the initial pairs are symmetric, this should result in all pairs (x, y) for x and y in 0 .. 11.

use datafrog::{Iteration, Relation};

let mut iteration = Iteration::new();
let variable = iteration.variable::<(usize, usize)>("source");
variable.insert(Relation::from((0 .. 10).map(|x| (x, x + 1))));
variable.insert(Relation::from((0 .. 10).map(|x| (x + 1, x))));

while iteration.changed() {
    variable.from_join(&variable, &variable, |&key, &val1, &val2| (val1, val2));
}

let result = variable.complete();
assert_eq!(result.len(), 121);
class Variable(TupleT)
void
fromJoin
(
alias Fn
Input1T
Input2T
)
(
Input1T input1
,
Input2T input2
)
if (
isTuple!TupleT
)

Meta