Commit 63ae145f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8e6bc9b7
......@@ -232,13 +232,16 @@ def Restructure(ztree, newStructure):
# - bucket.next_bucket will point to bucket that is coming next in the tree
tnew = newStructure.copy()
zlevelv = list(_zwalkBFS(ztree))
levelv = list( _walkBFS(tnew))
# assotiate every node in tnew to a znode
while len(levelv) > 0:
level = levelv.pop(0)
if len(zlevelv) == 0:
zrlevelv = list(__zwalkBFS(ztree)) # [] of _NodeInRange
rlevelv = list( __walkBFS(tnew)) # [] of _NodeInRange
# assotiate every non-bucket node in tnew to a znode
# extract bucket nodes.
zrbucketv = [] # of _NodeInRange
rbucketv = [] # of _NodeInRange
while len(rlevelv) > 0:
rlevel = rlevelv.pop(0)
if len(zrlevelv) == 0:
panic("TODO")
zlevel = zlevelv.pop(0)
......@@ -250,7 +253,24 @@ def Restructure(ztree, newStructure):
else:
panic("TODO")
if len(zlevelv) > 0:
if len(zrlevelv) > 0:
panic("TODO")
# TODO order queued buckets and zbuckets
# chain buckets via .next_bucket
assert len(rbucketv) > 0
for i in range(len(rbucketv)-1):
rbucketv[i].node.next_bucket = rbucketv[i+1].node
rbucketv[-1].node.next_bucket = None
# associate every bucket to zbucket
if len(zrbucketv) == len(rbucketv):
for (zrbucket, rbucket) in zip(zrbucketv, rbucketv):
rbucket.node.Z = zrbucket.node
else:
panic("TODO")
......@@ -442,7 +462,7 @@ class _Range:
return "[%s, %s)" % (r.klo, r.khi)
__repr__ = __str__
# _NodeInRange represents a node (node or znode) coming under range in its tree.
# _NodeInRange represents a node (node or znode) coming under key range in its tree.
class _NodeInRange:
# .range
# .node
......
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