Commit ba86a886 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7dbddf9d
......@@ -114,6 +114,18 @@ def patch(d, diff, verify):
if d[k] is not verify[k]:
panic("patch: verify: [%d] different: got %r; want %r" % (k, d[k], verify[k]))
# commit commits current transaction with description.
def commit(description):
txn = transaction.get()
txn.description = description
txn.commit()
# treetxt returns text representation of a tree.
def treetxt(ztree): # -> txt
return xbtree.TopoEncode(xbtree.StructureOf(ztree)) # FIXME include values
# XXX
#
# kv: k₁:v₁,k₂:v₂,...
......@@ -130,12 +142,13 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
# root['treedelta/values'] = {} v -> ZBlk(v)
valdict = root['treedelta/values'] = PersistentMapping()
for v in b'abcdefghi':
valv = b'abcdefghi'
for v in valv:
# XXX don't ovewrite if already set?
zblk = ZBlk()
zblk.setblkdata(v)
valdict[v] = zblk
transaction.commit()
commit('treedelta/values %s' % (list(valv),))
# 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'
......@@ -152,8 +165,6 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
diff12 = diff(kv1, kv2) # of (k,v) diff to go from kv1 to kv2
diff21 = diff(kv2, kv1) # of (k,v) diff to go from kv2 to kv1
#print('diff12:', diff12)
#print('diff21:', diff21)
maxdepth=2 # XXX -> 3?
maxsplit=1 # XXX -> 2?
......@@ -162,15 +173,19 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
# emit initial kv1 state prepared as ZODB would natively
ztree = root['treedelta/tree'] = BTrees.LOBTree.LOBTree() # XXX -> XLOTree (small nodes)
commit('treedelta/tree')
for k in sorted(kv1):
ztree[k] = kv1[k]
transaction.commit()
ztxt = treetxt(ztree)
commit(ztxt)
# XXX print txnδ
t1struct0 = xbtree.StructureOf(ztree)
# emit initial kv2 state prepared as ZODB would natively
patch(ztree, diff12, verify=kv2)
transaction.commit()
ztxt_prev = ztxt
ztxt = treetxt(ztree)
commit('%s -> %s' % (ztxt_prev, ztxt))
# XXX printδ
t2struct0 = xbtree.StructureOf(ztree)
......
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