|
|
@ -295,17 +295,8 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> { |
|
|
|
} |
|
|
|
} |
|
|
|
PlanNode::HashDeduplicate { child } => { |
|
|
|
PlanNode::HashDeduplicate { child } => { |
|
|
|
let iter = self.eval_plan(&*child, from); |
|
|
|
let iter = self.eval_plan(&*child, from); |
|
|
|
let mut values = HashSet::with_capacity(iter.size_hint().0); |
|
|
|
let already_seen = HashSet::with_capacity(iter.size_hint().0); |
|
|
|
let mut errors = Vec::default(); |
|
|
|
Box::new(HashDeduplicateIterator { iter, already_seen }) |
|
|
|
for result in iter { |
|
|
|
|
|
|
|
match result { |
|
|
|
|
|
|
|
Ok(result) => { |
|
|
|
|
|
|
|
values.insert(result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Err(error) => errors.push(Err(error)), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Box::new(errors.into_iter().chain(values.into_iter().map(Ok))) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
PlanNode::Skip { child, count } => Box::new(self.eval_plan(&*child, from).skip(*count)), |
|
|
|
PlanNode::Skip { child, count } => Box::new(self.eval_plan(&*child, from).skip(*count)), |
|
|
|
PlanNode::Limit { child, count } => { |
|
|
|
PlanNode::Limit { child, count } => { |
|
|
@ -1048,6 +1039,26 @@ impl<'a, S: EncodedQuadsStore> Iterator for UnionIterator<'a, S> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct HashDeduplicateIterator<'a> { |
|
|
|
|
|
|
|
iter: EncodedTuplesIterator<'a>, |
|
|
|
|
|
|
|
already_seen: HashSet<EncodedTuple>, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl<'a> Iterator for HashDeduplicateIterator<'a> { |
|
|
|
|
|
|
|
type Item = Result<EncodedTuple>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn next(&mut self) -> Option<Result<EncodedTuple>> { |
|
|
|
|
|
|
|
match self.iter.next()? { |
|
|
|
|
|
|
|
Ok(tuple) => if self.already_seen.insert(tuple.clone()) { |
|
|
|
|
|
|
|
Some(Ok(tuple)) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
self.next() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Err(error) => Some(Err(error)), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
struct ConstructIterator<'a, S: EncodedQuadsStore> { |
|
|
|
struct ConstructIterator<'a, S: EncodedQuadsStore> { |
|
|
|
store: Arc<S>, |
|
|
|
store: Arc<S>, |
|
|
|
iter: EncodedTuplesIterator<'a>, |
|
|
|
iter: EncodedTuplesIterator<'a>, |
|
|
|