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
bdbe0182
Commit
bdbe0182
authored
May 26, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
686d0ff1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
10 deletions
+39
-10
wcfs/testprog/treegen.py
wcfs/testprog/treegen.py
+39
-10
No files found.
wcfs/testprog/treegen.py
View file @
bdbe0182
...
...
@@ -22,10 +22,10 @@
It is used as helper for ΔBTree tests.
T
reegen provides the following subcommands
:
T
he following subcommands are provided
:
- `trees` generates trees specified as arguments,
- `allstructs` generates subset of all possible tree changes in between to
- `allstructs` generates subset of all possible tree changes in between t
w
o
trees represented by two key->value dicts.
...
...
@@ -89,10 +89,10 @@ from zodbtools.util import storageFromURL, ashex
from
persistent
import
CHANGED
from
persistent.mapping
import
PersistentMapping
# XXX hack: set LOBTree.LOBTree -> XLOTree so that nodes are split often
#
(XLOTree is LOBTree with small .max_*_size). Do it this way so that generated
#
database looks as if regular LOBTree was used. We use the hack beca
use
# we cannot tune LOBTree directly.
# XXX hack: set LOBTree.LOBTree -> XLOTree so that nodes are split often
for
#
regular tree updates (XLOTree is LOBTree with small .max_*_size). Do it this
#
way so that generated database looks as if regular LOBTree was used. We
use
#
the hack because
we cannot tune LOBTree directly.
XLOTree
=
xbtree_test
.
XLOTree
XLOTree
.
__module__
=
'BTrees.LOBTree'
XLOTree
.
__name__
=
'LOBTree'
...
...
@@ -113,7 +113,7 @@ class ZCtx(object):
zctx
.
zconn
=
zctx
.
db
.
open
()
zctx
.
root
=
zctx
.
zconn
.
root
()
# root['treegen/values'] = {} v -> ZBlk(v)
#
init
root['treegen/values'] = {} v -> ZBlk(v)
# TODO don't generate if already there
zctx
.
valdict
=
zctx
.
root
[
'treegen/values'
]
=
PersistentMapping
()
valv
=
b'abcdefghi'
...
...
@@ -123,6 +123,7 @@ class ZCtx(object):
zctx
.
valdict
[
v
]
=
zblk
commit
(
'treegen/values -> %r'
%
valv
)
# close release resources associated with zctx.
def
close
(
zctx
):
zctx
.
zconn
.
close
()
zctx
.
db
.
close
()
...
...
@@ -140,8 +141,36 @@ class ZCtx(object):
# XXX doc
@
func
def
Trees
(
zstor
,
r
):
for
l
in
r
.
readlines
():
1
/
0
zctx
=
ZCtx
(
zstor
)
defer
(
zctx
.
close
)
trees
=
zctx
.
root
.
get
(
'treegen/trees'
)
if
trees
is
None
:
trees
=
zctx
.
root
[
'treegen/trees'
]
=
PersistentMapping
()
commit
(
'mk treegen/trees'
)
for
treetxt
in
r
.
readlines
():
tree
=
zctx
.
TopoDecode
(
treetxt
)
ztree
=
trees
[
treetxt
]
=
LOBTree
()
# tree[k]=v for all k
# do tree.keys() via walkBFS
for
level
in
xbtree
.
_walkBFS
(
tree
):
for
node
in
level
:
if
isinstance
(
node
,
xbtree
.
Bucket
):
assert
node
.
valuev
is
not
None
assert
len
(
node
.
keyv
)
==
len
(
node
.
valuev
)
for
(
k
,
v
)
in
zip
(
node
.
keyv
,
node
.
valuev
):
ztree
[
k
]
=
v
# restructure to requested topology
xbtree
.
Restructure
(
ztree
,
tree
)
tid
=
commit
(
treetxt
)
# XXX print more details
print
(
"txn %s -> tree(%s) %s"
%
(
ashex
(
tid
),
ashex
(
ztree
.
_p_oid
),
treetxt
))
# AllStructs generates subset of all possible tree changes in
...
...
@@ -171,7 +200,7 @@ def AllStructs(zstor, kv1txt, kv2txt, n, seed=None):
t2AllStructs
=
list
(
xbtree
.
AllStructs
(
kv2
.
keys
(),
maxdepth
,
maxsplit
))
# create the tree
ztree
=
zctx
.
root
[
'treegen/tree'
]
=
XLOTree
()
ztree
=
zctx
.
root
[
'treegen/tree'
]
=
XLOTree
()
# XXX -> treegen/allstructs ?
commit
(
'treegen/tree'
)
# XXX print something?
...
...
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