Commit ea457e4a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent da7b19e3
...@@ -22,8 +22,10 @@ from __future__ import print_function, absolute_import ...@@ -22,8 +22,10 @@ from __future__ import print_function, absolute_import
from wendelin.wcfs.internal import xbtree from wendelin.wcfs.internal import xbtree
from BTrees.LOBTree import LOBTree from BTrees.LOBTree import LOBTree, LOBucket
from BTrees.tests import testBTrees from BTrees.tests import testBTrees
from BTrees import check as bcheck
from persistent import Persistent
def test_structureOf(): def test_structureOf():
T = xbtree.Tree T = xbtree.Tree
...@@ -280,28 +282,40 @@ class XBlk(Persistent): ...@@ -280,28 +282,40 @@ class XBlk(Persistent):
def __str__(self): def __str__(self):
return 'X%s' % self.data 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(): def test_restructure():
T = xbtree.Tree #T = xbtree.Tree
B = xbtree.Bucket #B = xbtree.Bucket
1/0 #1/0
# XXX -> import?
BTREE_EMPTY = bcheck.BTREE_EMPTY
BTREE_ONE = bcheck.BTREE_ONE
BTREE_NORMAL= bcheck.BTREE_NORMAL
N = 8 # maxkey N = 8 # maxkey
X = [] # X[i] = XBlk corresponding to block #i X = [] # X[i] = XBlk corresponding to block #i
for i in range(N): for i in range(N):
zblkv.append(XBlk('abcdefgh'[i])) X.append(XBlk('abcdefgh'[i]))
# prepare ztree with given keys via usual way # prepare ztree with given keys via usual way
def Z(*keys): def Z(*keys):
ztree = IOTree() # XXX -> class with node size=2 ztree = XLOTree() # XXX -> class with node size=2
for k in keys: for k in keys:
ztree[k] = zblkv[k] ztree[k] = X[k]
return ztree return ztree
# XXX check all keys by [] access # XXX check all keys by [] access
# XXX check all keys via iterating (this verifies firstbucket and B->next pointers) # 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): def R(ztree, newtopo):
newStructure = xbtree.TopoDecode(newtopo) newStructure = xbtree.TopoDecode(newtopo)
xbtree.Restructure(ztree, newStructure) xbtree.Restructure(ztree, newStructure)
...@@ -309,26 +323,26 @@ def test_restructure(): ...@@ -309,26 +323,26 @@ def test_restructure():
# Z0 creates new empty tree # Z0 creates new empty tree
def Z0(): def Z0():
z = Z() z = Z()
assert bcheck.crack_btree() == BTREE_EMPTY, [], [] assert bcheck.crack_btree() == (BTREE_EMPTY, [], [])
return z return z
# ø -> T/B # ø -> T/B
z = Z0() z = Z0()
R(z, 'T/B') 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 # ø -> T/T/B
z = Z0() z = Z0()
R(z, 'T/T/B') R(z, 'T/T/B')
kind, keys, kids = bcheck.crack_btree(z) kind, keys, kids = bcheck.crack_btree(z)
assert kind, keys == BTREE_NORMAL, [] assert kind, keys == (BTREE_NORMAL, [])
assert len(kids) == 0 assert len(kids) == 0
assert isinstance(kids[0], IOTree) assert isinstance(kids[0], XLOTree)
kind, keys, kids = bcheck.crack_btree(kids[0]) kind, keys, kids = bcheck.crack_btree(kids[0])
assert kind, keys == BTREE_NORMAL, [] # XXX or should it be BTREE_ONE here? assert kind, keys == (BTREE_NORMAL, []) # XXX or should it be BTREE_ONE here?
# XXX no: we need to wire bucket->next properly # XXX no: we need to wire bucket->next properly
assert len(kids) == 0 assert len(kids) == 0
assert isinstance(kids[0], IOBucket) assert isinstance(kids[0], LOBucket)
assert kids[0].keys() == [] assert kids[0].keys() == []
# XXX ø -> T/T-B/B # XXX ø -> T/T-B/B
...@@ -338,7 +352,7 @@ def test_restructure(): ...@@ -338,7 +352,7 @@ def test_restructure():
# tree with one not-yet committed bucket # tree with one not-yet committed bucket
z = Z(1, 3) 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 # XXX tree with one committed bucket
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment