Created
June 5, 2015 04:09
-
-
Save jamii/ae46e8e0c9757330e9ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn join_step<'a>(join: &'a Join, ix: usize, inputs: &[&'a Relation], state: &mut Vec<&'a Value>, index: &mut BTreeSet<Vec<Value>>) { | |
if ix == join.sources.len() { | |
index.insert(join.select.select(&state[..])); | |
} else { | |
match join.sources[ix] { | |
JoinSource::Relation{input} => { | |
for values in inputs[input].index.iter() { | |
push_all(state, values); | |
if join.constraints[ix].iter().all(|constraint| constraint.is_satisfied_by(&state[..])) { | |
join_step(join, ix+1, inputs, state, index) | |
} | |
pop_all(state, values); | |
} | |
} | |
JoinSource::Primitive{ref primitive, ref arguments, ..} => { | |
for values in primitive.eval_from_join(&arguments[..], &state[..]).into_iter() { | |
// promise the borrow checker that we will pop values before we exit this scope | |
let values = unsafe { ::std::mem::transmute::<&Vec<Value>, &'a Vec<Value>>(&values) }; | |
push_all(state, values); | |
if join.constraints[ix].iter().all(|constraint| constraint.is_satisfied_by(&state[..])) { | |
join_step(join, ix+1, inputs, state, index) | |
} | |
pop_all(state, values); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment