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

.

parent 8e6bc9b7
...@@ -232,13 +232,16 @@ def Restructure(ztree, newStructure): ...@@ -232,13 +232,16 @@ def Restructure(ztree, newStructure):
# - bucket.next_bucket will point to bucket that is coming next in the tree # - bucket.next_bucket will point to bucket that is coming next in the tree
tnew = newStructure.copy() tnew = newStructure.copy()
zlevelv = list(_zwalkBFS(ztree)) zrlevelv = list(__zwalkBFS(ztree)) # [] of _NodeInRange
levelv = list( _walkBFS(tnew)) rlevelv = list( __walkBFS(tnew)) # [] of _NodeInRange
# assotiate every node in tnew to a znode # assotiate every non-bucket node in tnew to a znode
while len(levelv) > 0: # extract bucket nodes.
level = levelv.pop(0) zrbucketv = [] # of _NodeInRange
if len(zlevelv) == 0: rbucketv = [] # of _NodeInRange
while len(rlevelv) > 0:
rlevel = rlevelv.pop(0)
if len(zrlevelv) == 0:
panic("TODO") panic("TODO")
zlevel = zlevelv.pop(0) zlevel = zlevelv.pop(0)
...@@ -250,7 +253,24 @@ def Restructure(ztree, newStructure): ...@@ -250,7 +253,24 @@ def Restructure(ztree, newStructure):
else: else:
panic("TODO") 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") panic("TODO")
...@@ -442,7 +462,7 @@ class _Range: ...@@ -442,7 +462,7 @@ class _Range:
return "[%s, %s)" % (r.klo, r.khi) return "[%s, %s)" % (r.klo, r.khi)
__repr__ = __str__ __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: class _NodeInRange:
# .range # .range
# .node # .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