MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / print_node

Method print_node

rust/src/validation.rs:324–358  ·  view source on GitHub ↗

Print a node and its children recursively for debugging.

(&self, node: &NodeRef<K, V>, depth: usize)

Source from the content-addressed store, hash-verified

322
323 /// Print a node and its children recursively for debugging.
324 fn print_node(&self, node: &NodeRef<K, V>, depth: usize) {
325 let indent = " ".repeat(depth);
326 match node {
327 NodeRef::Leaf(id, _) => {
328 if let Some(leaf) = self.get_leaf(*id) {
329 println!(
330 "{}Leaf[id={}, cap={}]: {} keys",
331 indent,
332 id,
333 leaf.capacity,
334 leaf.keys_len()
335 );
336 } else {
337 println!("{}Leaf[id={}]: <missing>", indent, id);
338 }
339 }
340 NodeRef::Branch(id, _) => {
341 if let Some(branch) = self.get_branch(*id) {
342 println!(
343 "{}Branch[id={}, cap={}]: {} keys, {} children",
344 indent,
345 id,
346 branch.capacity,
347 branch.keys.len(),
348 branch.children.len()
349 );
350 for child in &branch.children {
351 self.print_node(child, depth + 1);
352 }
353 } else {
354 println!("{}Branch[id={}]: <missing>", indent, id);
355 }
356 }
357 }
358 }
359
360 // ============================================================================
361 // VALIDATION HELPERS FOR OPERATIONS

Callers 1

print_node_chainMethod · 0.80

Calls 2

get_leafMethod · 0.80
get_branchMethod · 0.80

Tested by

no test coverage detected