feat: Improve RadixTree debugging output
- Enable printing of RadixTree debug information: The `debug_db` and `print_tree_from_node` functions now print detailed information about the RadixTree's internal structure, aiding in debugging. This improves the developer experience by providing better tools for understanding and troubleshooting issues within the RadixTree. - Remove unnecessary comments: Unnecessary comments in the `debug_db` function have been removed to improve code clarity.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
module radixtree
|
||||
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
// Gets a node from the database by its ID
|
||||
pub fn (mut rt RadixTree) get_node_by_id(id u32) !Node {
|
||||
node_data := rt.db.get(id)!
|
||||
@@ -29,18 +31,18 @@ pub fn (mut rt RadixTree) debug_db() ! {
|
||||
for id := u32(0); id < next_id; id++ {
|
||||
if data := rt.db.get(id) {
|
||||
if node := deserialize_node(data) {
|
||||
// console.print_debug('ID ${id}:')
|
||||
// console.print_debug(' Key Segment: "${node.key_segment}"')
|
||||
// console.print_debug(' Is Leaf: ${node.is_leaf}')
|
||||
// console.print_debug(' Children: ${node.children.len}')
|
||||
console.print_debug('ID ${id}:')
|
||||
console.print_debug(' Key Segment: "${node.key_segment}"')
|
||||
console.print_debug(' Is Leaf: ${node.is_leaf}')
|
||||
console.print_debug(' Children: ${node.children.len}')
|
||||
for child in node.children {
|
||||
// console.print_debug(' - Child ID: ${child.node_id}, Key Part: "${child.key_part}"')
|
||||
console.print_debug(' - Child ID: ${child.node_id}, Key Part: "${child.key_part}"')
|
||||
}
|
||||
} else {
|
||||
// console.print_debug('ID ${id}: Failed to deserialize node')
|
||||
console.print_debug('ID ${id}: Failed to deserialize node')
|
||||
}
|
||||
} else {
|
||||
// console.print_debug('ID ${id}: No data')
|
||||
console.print_debug('ID ${id}: No data')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +68,7 @@ pub fn (mut rt RadixTree) print_tree_from_node(node_id u32, indent string) ! {
|
||||
}
|
||||
node_info += ']'
|
||||
}
|
||||
// console.print_debug(node_info)
|
||||
console.print_debug(node_info)
|
||||
|
||||
// Print children recursively with increased indentation
|
||||
for i, child in node.children {
|
||||
|
||||
Reference in New Issue
Block a user