Commit e5aef07a authored by Kirill Smelkov's avatar Kirill Smelkov

.

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