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
04f722ae
Commit
04f722ae
authored
May 22, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ba86a886
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
24 deletions
+51
-24
wcfs/testprog/treedelta-genallstructs.py
wcfs/testprog/treedelta-genallstructs.py
+51
-24
No files found.
wcfs/testprog/treedelta-genallstructs.py
View file @
04f722ae
...
@@ -148,7 +148,7 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
...
@@ -148,7 +148,7 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
zblk
=
ZBlk
()
zblk
=
ZBlk
()
zblk
.
setblkdata
(
v
)
zblk
.
setblkdata
(
v
)
valdict
[
v
]
=
zblk
valdict
[
v
]
=
zblk
commit
(
'treedelta/values %
s'
%
(
list
(
valv
),)
)
commit
(
'treedelta/values %
r'
%
valv
)
# vdecode(vtxt) -> vobj 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'
# vencode(vobj) -> vtxt encodes value object into value text, e.g. ZBlk(a) -> 'a'
...
@@ -176,16 +176,16 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
...
@@ -176,16 +176,16 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
commit
(
'treedelta/tree'
)
commit
(
'treedelta/tree'
)
for
k
in
sorted
(
kv1
):
for
k
in
sorted
(
kv1
):
ztree
[
k
]
=
kv1
[
k
]
ztree
[
k
]
=
kv1
[
k
]
z
txt
=
treetxt
(
ztree
)
t
txt
=
treetxt
(
ztree
)
commit
(
z
txt
)
commit
(
t
txt
)
# XXX print txnδ
# XXX print txnδ
t1struct0
=
xbtree
.
StructureOf
(
ztree
)
t1struct0
=
xbtree
.
StructureOf
(
ztree
)
# emit initial kv2 state prepared as ZODB would natively
# emit initial kv2 state prepared as ZODB would natively
patch
(
ztree
,
diff12
,
verify
=
kv2
)
patch
(
ztree
,
diff12
,
verify
=
kv2
)
ztxt_prev
=
z
txt
ttxt_prev
=
t
txt
z
txt
=
treetxt
(
ztree
)
t
txt
=
treetxt
(
ztree
)
commit
(
'%s -> %s'
%
(
ztxt_prev
,
z
txt
))
commit
(
'%s -> %s'
%
(
ttxt_prev
,
t
txt
))
# XXX printδ
# XXX printδ
t2struct0
=
xbtree
.
StructureOf
(
ztree
)
t2struct0
=
xbtree
.
StructureOf
(
ztree
)
...
@@ -194,27 +194,54 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
...
@@ -194,27 +194,54 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
t2structv
=
[
t2struct0
]
+
random
.
sample
(
t2AllStructs
,
min
(
n
,
len
(
t2AllStructs
)))
t2structv
=
[
t2struct0
]
+
random
.
sample
(
t2AllStructs
,
min
(
n
,
len
(
t2AllStructs
)))
# emit tree1->tree2 and tree1<-tree2 transitions for all combinations of tree1 and tree2.
# emit tree1->tree2 and tree1<-tree2 transitions for all combinations of tree1 and tree2.
for
i
in
range
(
len
(
t1structv
)):
# tree1₀->tree2₀ was already emitted.
for
j
in
range
(
len
(
t2structv
)):
t12travel
=
list
(
bitravel2Way
(
t1structv
,
t2structv
))
tree1
=
t1structv
[
i
]
assert
t12travel
[
0
]
is
t1struct0
tree2
=
t2structv
[
j
]
assert
t12travel
[
1
]
is
t2struct0
for
i
,
tstruct
in
enumerate
(
t12travel
[
2
:]):
# tree1->tree2
if
i
%
2
==
0
:
if
not
(
i
==
0
and
j
==
0
):
delta
=
diff21
# tree1₀->tree2₀ was already emitted while initializing.
verify
=
kv1
patch
(
ztree
,
diff12
,
verify
=
kv2
)
assert
tstruct
in
t1structv
xbtree
.
Restructure
(
ztree
,
tree2
)
else
:
transaction
.
commit
()
delta
=
diff12
# XXX printδ
verify
=
kv2
assert
tstruct
in
t2structv
# tree1<-tree2
patch
(
ztree
,
diff21
,
verify
=
kv1
)
patch
(
ztree
,
delta
,
verify
)
xbtree
.
Restructure
(
ztree
,
tree1
)
xbtree
.
Restructure
(
ztree
,
tstruct
)
transaction
.
commit
()
ttxt_prev
=
ttxt
# XXX printδ
ttxt
=
xbtree
.
TopoEncode
(
tstruct
)
# XXX with values
commit
(
'%s -> %s'
%
(
ttxt_prev
,
ttxt
))
# XXX printδ
# bitravel2Way generates travel path through all A<->B edges such
# that all edges a->b and a<-b are traveled and exactly once.
#
# The travel starts from A[0].
def
bitravel2Way
(
A
,
B
):
# -> i[] of node
na
=
len
(
A
);
assert
na
>
0
nb
=
len
(
B
);
assert
nb
>
0
yield
A
[
0
]
# A₀
for
j
in
range
(
nb
):
yield
B
[
j
]
# A₀ -> Bj
for
i
in
range
(
1
,
na
):
yield
A
[
i
]
# Ai <- Bj
yield
B
[
j
]
# Ai -> Bj
yield
A
[
0
]
# A₀ <- Bj
def
test_bitravel2Way
():
a
,
b
,
c
=
'a'
,
'b'
,
'c'
A
=
[
a
,
b
,
c
]
B
=
[
1
,
2
]
assert
list
(
bitravel2Way
(
A
,
B
))
==
[
a
,
1
,
b
,
1
,
c
,
1
,
a
,
2
,
b
,
2
,
c
,
2
,
a
,
3
,
b
,
3
,
c
,
3
,
a
]
test_bitravel2Way
()
@
func
@
func
def
main
():
def
main
():
if
len
(
sys
.
argv
)
!=
5
:
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