Commit e5aef07a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1cbf4b33
......@@ -288,14 +288,18 @@ def Restructure(ztree, newStructure):
# extract bucket nodes.
zrbucketv = [] # of _NodeInRange
rbucketv = [] # of _NodeInRange
while len(rlevelv) > 0:
while len(rlevelv) > 0 or len(zrlevelv) > 0:
if len(rlevelv) == 0:
rlevel = []
else:
rlevel = rlevelv.pop(0)
if len(zrlevelv) == 0:
zrlevel = []
else:
zrlevel = zrlevelv.pop(0)
# filter-out buckets
# filter-out buckets to be processed in the end
_ = [] # zrlevel -> zrlevel, zrbucketv
for zrn in zrlevel:
assert isinstance(zrn.node, (ztreeType, zbucketType))
......@@ -313,16 +317,21 @@ def Restructure(ztree, newStructure):
_.append(rn)
rlevel = _
if len(rlevel) == 0:
continue
# associate nodes to znodes
assign(zrlevel, rlevel)
"""
if len(zrlevel) == len(rlevel): # map 1-1
for (zrn, rn) in zip(zrlevel, rlevel):
rn.node.Z = zrn.node
else:
panic("TODO")
"""
if len(zrlevelv) > 0:
panic("TODO")
assert zrlevelv == []
assert rlevelv == []
# order queued buckets and zbuckets by key↑
zrbucketv.sort(key = lambda rn: rn.range.klo)
......@@ -336,12 +345,14 @@ def Restructure(ztree, newStructure):
rbucketv[-1].node.next_bucket = None
# associate every bucket to zbucket
assign(zrbucketv, rbucketv)
"""
if len(zrbucketv) == len(rbucketv):
for (zrbucket, rbucket) in zip(zrbucketv, rbucketv):
rbucket.node.Z = zrbucket.node
else:
panic("TODO")
"""
# set znode states according to established tnew->znode association
......
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