Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
ba86a886
Commit
ba86a886
authored
May 22, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7dbddf9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
wcfs/testprog/treedelta-genallstructs.py
wcfs/testprog/treedelta-genallstructs.py
+21
-6
No files found.
wcfs/testprog/treedelta-genallstructs.py
View file @
ba86a886
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment