Commit c98d3f92 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 98337e00
...@@ -151,9 +151,9 @@ def Trees(zstor, r): ...@@ -151,9 +151,9 @@ def Trees(zstor, r):
zctx = ZCtx(zstor) zctx = ZCtx(zstor)
defer(zctx.close) defer(zctx.close)
tree = zctx.root['treegen/tree'] = XLOTree() ztree = zctx.root['treegen/tree'] = XLOTree()
at0 = commit('treegen/tree: init') at0 = commit('treegen/tree: init')
xprint("start @%s root=%s" % (ashex(at0), ashex(tree._p_oid))) xprint("start @%s root=%s" % (ashex(at0), ashex(ztree._p_oid)))
while 1: while 1:
treetxt = r.readline() treetxt = r.readline()
...@@ -162,11 +162,12 @@ def Trees(zstor, r): ...@@ -162,11 +162,12 @@ def Trees(zstor, r):
treetxt = treetxt.rstrip() # trim trailing \n treetxt = treetxt.rstrip() # trim trailing \n
tree = zctx.TopoDecode(treetxt) tree = zctx.TopoDecode(treetxt)
ztree = trees[treetxt] = XLOTree() # ztree = trees[treetxt] = XLOTree()
zctx.zconn.add(ztree) # so that restructure can see we are working under zconn # zctx.zconn.add(ztree) # so that restructure can see we are working under zconn
# tree[k]=v for all k # treekv[k]=v for all k
# do tree.keys() via walkBFS # do tree.keys() via walkBFS
treekv = {}
for level in xbtree._walkBFS(tree): for level in xbtree._walkBFS(tree):
for node in level: for node in level:
if isinstance(node, xbtree.Bucket): if isinstance(node, xbtree.Bucket):
...@@ -174,9 +175,13 @@ def Trees(zstor, r): ...@@ -174,9 +175,13 @@ def Trees(zstor, r):
panic("%s: tree must be {key->value}, not set" % treetxt) panic("%s: tree must be {key->value}, not set" % treetxt)
assert len(node.keyv) == len(node.valuev) assert len(node.keyv) == len(node.valuev)
for (k,v) in zip(node.keyv, node.valuev): for (k,v) in zip(node.keyv, node.valuev):
ztree[k] = v treekv[k] = v
# restructure to requested topology # change ztree to requested kv
d = diff(ztree, treekv)
patch(ztree, d, treekv)
# restructure ztree to requested topology
xbtree.Restructure(ztree, tree) xbtree.Restructure(ztree, tree)
tid = commit("treegen/trees: %s" % treetxt) tid = commit("treegen/trees: %s" % treetxt)
......
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