Rough implementation of btree append

This involves many, many hacks, but is enough to test the concept
and start looking at how it interacts with different block sizes.

Note only append (lfsr_btree_push on the end) is implemented, and it
makes some assumption about how the ids can interact when splitting
rbyds.
This commit is contained in:
Christopher Haster
2023-03-02 21:46:23 -06:00
parent 361dfb0625
commit 88e3db98a9
4 changed files with 626 additions and 117 deletions

View File

@@ -62,6 +62,8 @@ def tagrepr(tag, id, w, size, off=None):
id,
' w%d' % w if w is not None else '',
size)
elif tag == 0x0800:
return 'inlined id%d %d' % (id, size)
elif tag == 0x0810:
return 'block id%d %d' % (id, size)
elif tag == 0x0820:
@@ -565,6 +567,7 @@ def show_tree(block_size, data, rev, trunk, weight, *,
def main(disk, block_size=None, block1=0, block2=None, *,
limit=None,
trunk=None,
color='auto',
**args):
@@ -582,6 +585,10 @@ def main(disk, block_size=None, block1=0, block2=None, *,
f.seek(0, os.SEEK_END)
block_size = f.tell()
# default limit to the block_size
if limit is None:
limit = block_size
# read each block
blocks = [block for block in [block1, block2] if block is not None]
datas = []
@@ -600,7 +607,7 @@ def main(disk, block_size=None, block1=0, block2=None, *,
weight = 0
weight_ = 0
wastrunk = False
while j_ < block_size:
while j_ < limit:
v, tag, id, size, delta = fromtag(data[j_:])
if v != (popc(crc) & 1):
break
@@ -682,11 +689,6 @@ if __name__ == "__main__":
parser.add_argument(
'disk',
help="File containing the block device.")
parser.add_argument(
'block_size',
nargs='?',
type=lambda x: int(x, 0),
help="Block size in bytes.")
parser.add_argument(
'block1',
nargs='?',
@@ -697,6 +699,14 @@ if __name__ == "__main__":
nargs='?',
type=lambda x: int(x, 0),
help="Block address of the second metadata block.")
parser.add_argument(
'-B', '--block-size',
type=lambda x: int(x, 0),
help="Block size in bytes.")
parser.add_argument(
'-L', '--limit',
type=lambda x: int(x, 0),
help="Use this offset as the rbyd limit.")
parser.add_argument(
'--trunk',
type=lambda x: int(x, 0),