Commit 8ae42901 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 82a5c353
...@@ -292,22 +292,12 @@ def Restructure(ztree, newStructure): ...@@ -292,22 +292,12 @@ def Restructure(ztree, newStructure):
# set znode states according to established tnew->znode association # set znode states according to established tnew->znode association
for nodev in levelv: for rnodev in rlevelv:
for node in nodev: for rn in rnodev:
node = rn.node
assert isinstance(node, Tree) # buckets were filtered out to rbucketv
znode = node.Z znode = node.Z
if isinstance(node, Bucket):
# https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BucketTemplate.c#L1195
zstate = ()
for k in node.keyv:
zstate += (k, kv.pop(k)) # (k1, v1, k2, v2, ..., kN, vN)
zstate = (zstate,)
if node.next_bucket is not None: # next
zstate += (node.next_bucket.Z,)
else:
assert isinstance(node, Tree)
# https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BTreeTemplate.c#L1087 # https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BTreeTemplate.c#L1087
if len(node.keyv) == 0: if len(node.keyv) == 0:
panic("TODO: empty tree + tree with bucket without oid") panic("TODO: empty tree + tree with bucket without oid")
...@@ -324,6 +314,21 @@ def Restructure(ztree, newStructure): ...@@ -324,6 +314,21 @@ def Restructure(ztree, newStructure):
znode.__setstate__(zstate) znode.__setstate__(zstate)
# ----//---- for buckets
for rbucket in rbucketv:
node = rbucket.node
# https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BucketTemplate.c#L1195
zstate = ()
for k in node.keyv:
zstate += (k, kv.pop(k)) # (k1, v1, k2, v2, ..., kN, vN)
zstate = (zstate,)
if node.next_bucket is not None: # next
zstate += (node.next_bucket.Z,)
node.Z.__setstate__(zstate)
assert tnew.Z is ztree assert tnew.Z is ztree
assert len(kv) == 0 # all keys must have been popped assert len(kv) == 0 # all keys must have been popped
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment