Closed ItsFunny closed 10 months ago
where's the seek and what's the issue?
this is my iter_all codes, I think i used in wrong way
fn iter_all<KF, VF, K, V>(
&mut self,
prefix: &[u8],
kf: KF,
vf: VF,
) -> IndexerResult<Vec<(K, V)>>
where
KF: Fn(Vec<u8>) -> K,
VF: Fn(Vec<u8>) -> Option<V>,
{
let mut db = self.db.borrow_mut();
let mut iter = db.new_iter()?;
iter.seek(prefix);
let mut ret = vec![];
let v = current_key_val(&iter);
if let Some((k, v)) = v {
let value = vf(v);
let key = kf(k);
if value.is_some() {
ret.push((key, value.unwrap()))
}
}
loop {
if !iter.valid() {
return Ok(ret);
}
let next = iter.next();
if next.is_none() {
return Ok(ret);
}
let (k, v) = next.unwrap();
let key = kf(k);
let value = vf(v);
if value.is_some() {
ret.push((key, value.unwrap()))
}
}
}
@dermesser Hi,please take a look
let mut db = LevelDB::default();