[array_walker] Read multiple array blocks at once

This commit is contained in:
Ming-Hung Tsai 2021-04-17 00:05:08 +08:00
parent c17559791f
commit 3279d8381b

View File

@ -53,21 +53,27 @@ impl<'a, V: Unpack + Copy> NodeVisitor<u64> for BlockValueVisitor<'a, V> {
let mut errs: Vec<BTreeError> = Vec::new(); let mut errs: Vec<BTreeError> = Vec::new();
// TODO: check index continuity // TODO: check index continuity
// FIXME: use IoEngine::read_many() match self.engine.read_many(values) {
for (n, index) in keys.iter().enumerate() { Err(_) => {
// IO completely failed on all the child blocks
// FIXME: count read errors on its parent (BTreeError::IoError) or on its location // FIXME: count read errors on its parent (BTreeError::IoError) or on its location
// (ArrayError::IoError)? // (ArrayError::IoError)?
let b = self.engine.read(values[n]).map_err(|_| btree::io_err(&path)); for (_i, _b) in values.iter().enumerate() {
if let Err(e) = b { errs.push(btree::io_err(&path)); // FIXME: add key_context
errs.push(e);
continue;
} }
let b = b.unwrap(); }
Ok(rblocks) => {
path.push(values[n]); for (i, rb) in rblocks.into_iter().enumerate() {
match rb {
Err(_) => {
errs.push(btree::io_err(&path)); // FIXME: add key_context
},
Ok(b) => {
path.push(b.loc);
match unpack_array_block::<V>(&path, b.get_data()) { match unpack_array_block::<V>(&path, b.get_data()) {
Ok(array_block) => { Ok(array_block) => {
if let Err(e) = self.array_visitor.visit(*index, array_block) { // FIXME: will the returned blocks be reordered?
if let Err(e) = self.array_visitor.visit(keys[i], array_block) {
self.array_errs.lock().unwrap().push(e); self.array_errs.lock().unwrap().push(e);
} }
}, },
@ -76,6 +82,10 @@ impl<'a, V: Unpack + Copy> NodeVisitor<u64> for BlockValueVisitor<'a, V> {
} }
} }
path.pop(); path.pop();
},
}
}
}
} }
// FIXME: duplicate to BTreeWalker::build_aggregrate() // FIXME: duplicate to BTreeWalker::build_aggregrate()