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
ceef9fba
Commit
ceef9fba
authored
May 22, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9bd4feda
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
wcfs/testprog/treedelta-genallstructs.py
wcfs/testprog/treedelta-genallstructs.py
+11
-8
No files found.
wcfs/testprog/treedelta-genallstructs.py
View file @
ceef9fba
...
...
@@ -64,13 +64,14 @@ import BTrees.LOBTree
#
# kv: k₁:v₁,k₂:v₂,...
@
func
def
treedeltaGenAllStructs
(
zstor
,
kv1txt
,
kv2txt
,
n
):
def
treedeltaGenAllStructs
(
zstor
,
kv1txt
,
kv2txt
,
n
,
seed
=
None
):
db
=
DB
(
zstor
);
defer
(
db
.
close
)
zconn
=
db
.
open
();
defer
(
zconn
.
close
)
root
=
zconn
.
root
()
# seed
seed
=
int
(
time
.
now
())
if
seed
is
None
:
seed
=
int
(
time
.
now
())
print
(
"# seed=%d"
%
seed
)
random
.
seed
(
seed
)
...
...
@@ -97,10 +98,10 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
kv2
=
kvDecode
(
kv2txt
,
vdecode
)
# δ kv1 <-> kv2
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
diff12
=
diff
(
kv1
,
kv2
)
diff21
=
diff
(
kv2
,
kv1
)
# all t
opology struct
s that can represent kv1 and kv2
# all t
ree topologie
s that can represent kv1 and kv2
maxdepth
=
2
# XXX -> 3?
maxsplit
=
1
# XXX -> 2?
t1AllStructs
=
list
(
xbtree
.
AllStructs
(
kv1
.
keys
(),
maxdepth
,
maxsplit
))
...
...
@@ -124,7 +125,8 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
vtxt
=
'ø'
if
v
is
not
DEL
:
vtxt
=
vencode
(
v
)
print
(
'
\
t
%d:%s'
%
(
k
,
vtxt
))
# XXX print not only +, but also - (e.g. -1:a +1:b) ?
# XXX print not only +, but also - (e.g. -1:a +1:b) ?
print
(
'
\
t
%d:%s'
%
(
k
,
vtxt
))
# emit initial kv1 and kv2 states prepared as ZODB would do natively
emit
(
diff
({},
kv1
),
verify
=
kv1
,
treeTopo
=
None
)
...
...
@@ -132,12 +134,13 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
emit
(
diff
(
kv1
,
kv2
),
verify
=
kv2
,
treeTopo
=
None
)
t2struct0
=
xbtree
.
StructureOf
(
ztree
)
# all tree1 and tree2 topologies we are going to emit: native + n random ones
# all tree1 and tree2 topologies jumps in between we are going to emit:
# native + n random ones.
t1structv
=
[
t1struct0
]
+
random
.
sample
(
t1AllStructs
,
min
(
n
,
len
(
t1AllStructs
)))
t2structv
=
[
t2struct0
]
+
random
.
sample
(
t2AllStructs
,
min
(
n
,
len
(
t2AllStructs
)))
# emit tree1->tree2 and tree1<-tree2 transitions for all combinations of tree1 and tree2.
# tree1₀->tree2₀ was already
emitted
.
# tree1₀->tree2₀ was already
done
.
t12travel
=
list
(
bitravel2Way
(
t1structv
,
t2structv
))
assert
t12travel
[
0
]
is
t1struct0
assert
t12travel
[
1
]
is
t2struct0
...
...
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