#![cfg(feature = "scheduler")]
use hyphae::{CellMap, MapQuery, batch, traits::InnerJoinExt};
const PAIRS: usize = 8;
const ITERATIONS: i64 = 3_000;
#[test]
fn concurrent_inner_joins_never_settle_on_a_torn_value() {
hyphae::scheduler::set_wave_threshold_for_test(4);
let mut lefts = Vec::new();
let mut rights = Vec::new();
let mut outputs = Vec::new();
for _ in 0..PAIRS {
let l = CellMap::<String, i64>::new();
let r = CellMap::<String, i64>::new();
l.insert("k".into(), 0);
r.insert("k".into(), 0);
let out = l.clone().inner_join(r.clone()).materialize();
lefts.push(l);
rights.push(r);
outputs.push(out);
}
for it in 1..=ITERATIONS {
batch(|| {
#[allow(clippy::needless_range_loop)]
for i in 0..PAIRS {
let base = it * 1000 + i as i64;
lefts[i].insert("k".into(), base);
rights[i].insert("k".into(), base + 500);
}
});
#[allow(clippy::needless_range_loop)]
for i in 0..PAIRS {
let base = it * 1000 + i as i64;
assert_eq!(
outputs[i].get_value(&"k".to_string()),
Some((base, base + 500)),
"inner_join settled on a torn/stale value at iteration {it}, pair {i}"
);
}
}
}