Commit 0992814c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e926e154
......@@ -79,7 +79,7 @@ def kvDecode(kvText, vdecode): # -> kvDict
#
# kv: k₁:v₁,k₂:v₂,...
@func
def treedeltaGenAllStructs(zstor, kv1, kv2, n):
def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
db = DB(zstor); defer(db.close)
zconn = db.open(); defer(zconn.close)
root = zconn.root()
......@@ -93,16 +93,46 @@ def treedeltaGenAllStructs(zstor, kv1, kv2, n):
valdict[v] = zblk
transaction.commit()
# vdecode decodes value text into value object, e.g. 'a' -> ZBlk(a)
# vdecode(vtxt) -> vobj decodes value text into value object, e.g. 'a' -> ZBlk(a)
# vencode(vobj) -> vtxt encodes value object into value text, e.g. ZBlk(a) -> 'a'
def vdecode(vtxt): # -> vobj
return valdict[vtxt]
# vencode encodes value object into value text, e.g. ZBlk(a) -> 'a'
def vencode(vobj): # -> vtxt
for (k,v) in valdict.items():
if v is vobj:
return k
raise KeyError("%r not found in value registry" % (vobj,))
kv1 = kvDecode(kv1txt, vdecode)
kv2 = kvDecode(kv2txt, vdecode)
diff12 = [] # of (k,v) diff to go from kv1 to kv2 XXX compute
diff21 = [] # of (k,v) diff to go from kv2 to kv1
maxdepth=2 # XXX -> 3?
maxsplit=1 # XXX -> 2?
t1structs = list(xbtree.AllStructs(kv1.keys(), maxdepth, maxsplit))
t2structs = list(xbtree.AllStructs(kv2.keys(), maxdepth, maxsplit))
# emit initial kv1 state prepared as ZODB would natively
ztree = valdict['treedelta/tree'] = XLOTree()
for k in sorted(kv1):
ztree[k] = kv1[k]
transaction.commit()
# XXX print
t1struct0 = xbtree.StructureOf(ztree)
# emit initial kv2 state prepared as ZODB would natively
for (k,v) in diff12:
if v is DEL:
del ztree[k]
else:
ztree[k] = v
transaction.commit()
# XXX print
t2struct0 = xbtree.StructureOf(ztree)
@func
def main():
if len(sys.argv) != 5:
......
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