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
0992814c
Commit
0992814c
authored
May 21, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e926e154
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
3 deletions
+33
-3
wcfs/testprog/treedelta-genallstructs.py
wcfs/testprog/treedelta-genallstructs.py
+33
-3
No files found.
wcfs/testprog/treedelta-genallstructs.py
View file @
0992814c
...
...
@@ -79,7 +79,7 @@ def kvDecode(kvText, vdecode): # -> kvDict
#
# kv: k₁:v₁,k₂:v₂,...
@
func
def
treedeltaGenAllStructs
(
zstor
,
kv1
,
kv2
,
n
):
def
treedeltaGenAllStructs
(
zstor
,
kv1
txt
,
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
:
...
...
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