1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use super::*;
use epoch::pin;
pub struct Iter<'a> {
pub(super) id: PageID,
pub(super) inner:
&'a PageCache<BLinkMaterializer, Frag, Vec<(PageID, PageID)>>,
pub(super) last_key: Bound,
}
impl<'a> Iterator for Iter<'a> {
type Item = (Vec<u8>, Vec<u8>);
fn next(&mut self) -> Option<Self::Item> {
let guard = pin();
loop {
let (frag, _cas_key) = self.inner.get(self.id, &guard).unwrap();
let (node, _is_root) = frag.base().unwrap();
for (ref k, ref v) in node.data.leaf().unwrap() {
if Bound::Inc(k.clone()) > self.last_key {
self.last_key = Bound::Inc(k.to_vec());
let ret = Some((k.clone(), v.clone()));
return ret;
}
}
if node.next.is_none() {
return None;
}
self.id = node.next.unwrap();
}
}
}