[thin_check (rust)] replace IndexVisitor with a call to btree_to_map
This commit is contained in:
parent
e28c602c3d
commit
55ee4bfad8
@ -141,31 +141,6 @@ impl Unpack for DeviceDetail {
|
|||||||
|
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
|
|
||||||
struct IndexVisitor {
|
|
||||||
entries: Vec<IndexEntry>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl NodeVisitor<IndexEntry> for IndexVisitor {
|
|
||||||
fn visit(&mut self, _w: &BTreeWalker, _b: &Block, node: &Node<IndexEntry>) -> Result<()> {
|
|
||||||
if let Node::Leaf {
|
|
||||||
header: _h,
|
|
||||||
keys: _k,
|
|
||||||
values,
|
|
||||||
} = node
|
|
||||||
{
|
|
||||||
for v in values {
|
|
||||||
// FIXME: check keys are in incremental order
|
|
||||||
let v = v.clone();
|
|
||||||
self.entries.push(v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------
|
|
||||||
|
|
||||||
struct OverflowChecker<'a> {
|
struct OverflowChecker<'a> {
|
||||||
data_sm: &'a dyn SpaceMap,
|
data_sm: &'a dyn SpaceMap,
|
||||||
}
|
}
|
||||||
@ -282,15 +257,11 @@ pub fn check(opts: &ThinCheckOptions) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bitmaps
|
// Bitmaps
|
||||||
let mut v = IndexVisitor {
|
let entries = btree_to_map::<IndexEntry>(engine.clone(), false, root.bitmap_root)?;
|
||||||
entries: Vec::new(),
|
eprintln!("{} index entries", entries.len());
|
||||||
};
|
|
||||||
let mut w = BTreeWalker::new(engine.clone(), false);
|
|
||||||
let _result = w.walk(&mut v, root.bitmap_root);
|
|
||||||
eprintln!("{} index entries", v.entries.len());
|
|
||||||
|
|
||||||
let mut blocks = Vec::new();
|
let mut blocks = Vec::new();
|
||||||
for i in &v.entries {
|
for (_k, i) in &entries {
|
||||||
blocks.push(Block::new(i.blocknr));
|
blocks.push(Block::new(i.blocknr));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +270,7 @@ pub fn check(opts: &ThinCheckOptions) -> Result<()> {
|
|||||||
let mut leaks = 0;
|
let mut leaks = 0;
|
||||||
let mut fail = false;
|
let mut fail = false;
|
||||||
let mut blocknr = 0;
|
let mut blocknr = 0;
|
||||||
for (n, _i) in v.entries.iter().enumerate() {
|
for n in 0..entries.len() {
|
||||||
let b = &blocks[n];
|
let b = &blocks[n];
|
||||||
if checksum::metadata_block_type(&b.get_data()) != checksum::BT::BITMAP {
|
if checksum::metadata_block_type(&b.get_data()) != checksum::BT::BITMAP {
|
||||||
return Err(anyhow!(
|
return Err(anyhow!(
|
||||||
|
Loading…
Reference in New Issue
Block a user