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
ea457e4a
Commit
ea457e4a
authored
May 11, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
da7b19e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
16 deletions
+30
-16
wcfs/internal/xbtree_test.py
wcfs/internal/xbtree_test.py
+30
-16
No files found.
wcfs/internal/xbtree_test.py
View file @
ea457e4a
...
...
@@ -22,8 +22,10 @@ from __future__ import print_function, absolute_import
from
wendelin.wcfs.internal
import
xbtree
from
BTrees.LOBTree
import
LOBTree
from
BTrees.LOBTree
import
LOBTree
,
LOBucket
from
BTrees.tests
import
testBTrees
from
BTrees
import
check
as
bcheck
from
persistent
import
Persistent
def
test_structureOf
():
T
=
xbtree
.
Tree
...
...
@@ -280,28 +282,40 @@ class XBlk(Persistent):
def
__str__
(
self
):
return
'X%s'
%
self
.
data
# XLOTree is like LOTree but with small max tree and bucket node sizes.
class
XLOTree
(
LOBTree
):
#_bucket_type = XLOBucket
max_leaf_size
=
2
max_internal_size
=
2
def
test_restructure
():
T
=
xbtree
.
Tree
B
=
xbtree
.
Bucket
1
/
0
#T = xbtree.Tree
#B = xbtree.Bucket
#1/0
# XXX -> import?
BTREE_EMPTY
=
bcheck
.
BTREE_EMPTY
BTREE_ONE
=
bcheck
.
BTREE_ONE
BTREE_NORMAL
=
bcheck
.
BTREE_NORMAL
N
=
8
# maxkey
X
=
[]
# X[i] = XBlk corresponding to block #i
for
i
in
range
(
N
):
zblkv
.
append
(
XBlk
(
'abcdefgh'
[
i
]))
X
.
append
(
XBlk
(
'abcdefgh'
[
i
]))
# prepare ztree with given keys via usual way
def
Z
(
*
keys
):
ztree
=
I
OTree
()
# XXX -> class with node size=2
ztree
=
XL
OTree
()
# XXX -> class with node size=2
for
k
in
keys
:
ztree
[
k
]
=
zblkv
[
k
]
ztree
[
k
]
=
X
[
k
]
return
ztree
# XXX check all keys by [] access
# XXX check all keys via iterating (this verifies firstbucket and B->next pointers)
# R restructures ztree
according to
new topology.
# R restructures ztree
to have specified
new topology.
def
R
(
ztree
,
newtopo
):
newStructure
=
xbtree
.
TopoDecode
(
newtopo
)
xbtree
.
Restructure
(
ztree
,
newStructure
)
...
...
@@ -309,26 +323,26 @@ def test_restructure():
# Z0 creates new empty tree
def
Z0
():
z
=
Z
()
assert
bcheck
.
crack_btree
()
==
BTREE_EMPTY
,
[],
[]
assert
bcheck
.
crack_btree
()
==
(
BTREE_EMPTY
,
[],
[])
return
z
# ø -> T/B
z
=
Z0
()
R
(
z
,
'T/B'
)
assert
bcheck
.
crack_btree
(
z
)
==
BTREE_NORMAL
,
[],
IOBucket
()
assert
bcheck
.
crack_btree
(
z
)
==
(
BTREE_NORMAL
,
[],
LOBucket
())
# XXX -> BTREE_ONE
# ø -> T/T/B
z
=
Z0
()
R
(
z
,
'T/T/B'
)
kind
,
keys
,
kids
=
bcheck
.
crack_btree
(
z
)
assert
kind
,
keys
==
BTREE_NORMAL
,
[]
assert
kind
,
keys
==
(
BTREE_NORMAL
,
[])
assert
len
(
kids
)
==
0
assert
isinstance
(
kids
[
0
],
I
OTree
)
assert
isinstance
(
kids
[
0
],
XL
OTree
)
kind
,
keys
,
kids
=
bcheck
.
crack_btree
(
kids
[
0
])
assert
kind
,
keys
==
BTREE_NORMAL
,
[]
# XXX or should it be BTREE_ONE here?
# XXX no: we need to wire bucket->next properly
assert
kind
,
keys
==
(
BTREE_NORMAL
,
[])
# XXX or should it be BTREE_ONE here?
# XXX no: we need to wire bucket->next properly
assert
len
(
kids
)
==
0
assert
isinstance
(
kids
[
0
],
I
OBucket
)
assert
isinstance
(
kids
[
0
],
L
OBucket
)
assert
kids
[
0
].
keys
()
==
[]
# XXX ø -> T/T-B/B
...
...
@@ -338,7 +352,7 @@ def test_restructure():
# tree with one not-yet committed bucket
z
=
Z
(
1
,
3
)
assert
bcheck
.
crack_btree
()
==
BTREE_ONE
,
(
1
,
X
[
1
],
3
,
X
[
3
]),
None
assert
bcheck
.
crack_btree
()
==
(
BTREE_ONE
,
(
1
,
X
[
1
],
3
,
X
[
3
]),
None
)
# XXX tree with one committed bucket
...
...
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