Adopted new tree renderer in dbgmtree, implemented mtree rendering

In addition to plugging in the rbyd and btree renderers in dbgbtree.py,
this required wiring in rbyd trees in the mdirs and mroots.

A bit tricky, but with a more-or-less straightforward implementation thanks
to the common edge description used for the tree renderer.

For example, a relatively small mtree:

  $ ./scripts/dbgmtree.py disk -B4096 -t -i
  mroot 0x{0,1}.45, rev 1, weight 0
  mdir                     ids   tag                     ...
  {0000,0001}: .--------->    -1 magic 8                 ...
               | .------->       config 21               ...
               +-+-+             btree 7                 ...
    0006.000a:     | .-+       0 mdir w1 2               ...
  {0002,0003}:     | | '->   0.0 inlined w1 1024         ...
    0006.000a:     '-+-+       1 mdir w1 2               ...
  {0004,0005}:         '->   1.0 inlined w1 1024         ...
This commit is contained in:
Christopher Haster
2023-05-21 02:27:09 -05:00
parent 9b803f9625
commit af0c3967b4
2 changed files with 964 additions and 203 deletions
+3 -5
View File
@@ -367,7 +367,7 @@ class Rbyd:
id = -1 id = -1
while True: while True:
done, id, tag, w, j, d, data = self.lookup(id, tag+0x10) done, id, tag, w, j, d, data, _ = self.lookup(id, tag+0x10)
if done: if done:
break break
@@ -628,7 +628,7 @@ def main(disk, roots=None, *,
'c': branch['c'], 'c': branch['c'],
}) })
d_ += max(rdepth, 1) d_ += max(bdepths.get(d, 0), 1)
leaf = (bid-(w-1), d, rid-(w-1), TAG_BTREE) leaf = (bid-(w-1), d, rid-(w-1), TAG_BTREE)
# remap branches to leaves if we aren't showing inner branches # remap branches to leaves if we aren't showing inner branches
@@ -679,7 +679,6 @@ def main(disk, roots=None, *,
tree = [] tree = []
root = None root = None
branches = {} branches = {}
leaves = {}
bid = -1 bid = -1
while True: while True:
done, bid, w, rbyd, rid, tags, path = btree_lookup( done, bid, w, rbyd, rid, tags, path = btree_lookup(
@@ -741,7 +740,6 @@ def main(disk, roots=None, *,
t_width = 2*t_depth + 2 t_width = 2*t_depth + 2
def treerepr(bid, w, bd, rid, tag): def treerepr(bid, w, bd, rid, tag):
# print('%-32s' % repr((bid-(w-1), bd, rid, tag)), end='')
if t_depth == 0: if t_depth == 0:
return '' return ''
@@ -873,6 +871,7 @@ def main(disk, roots=None, *,
if done: if done:
break break
# print inner btree entries if requested
if args.get('inner'): if args.get('inner'):
changed = False changed = False
for (x, px) in it.zip_longest( for (x, px) in it.zip_longest(
@@ -897,7 +896,6 @@ def main(disk, roots=None, *,
'\x1b[31m' if color else '', '\x1b[31m' if color else '',
'(corrupted rbyd %s)' % rbyd.addr(), '(corrupted rbyd %s)' % rbyd.addr(),
'\x1b[m' if color else '')) '\x1b[m' if color else ''))
prbyd = rbyd prbyd = rbyd
corrupted = True corrupted = True
continue continue
+961 -198
View File
File diff suppressed because it is too large Load Diff