Commit ea457e4a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent da7b19e3
......@@ -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 = IOTree() # XXX -> class with node size=2
ztree = XLOTree() # 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], IOTree)
assert isinstance(kids[0], XLOTree)
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], IOBucket)
assert isinstance(kids[0], LOBucket)
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
......
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