Commit edebb8ad authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8d90dfb2
...@@ -18,12 +18,10 @@ ...@@ -18,12 +18,10 @@
# See COPYING file for full licensing terms. # See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options. # See https://www.nexedi.com/licensing for rationale and options.
# XXX review
from __future__ import print_function, absolute_import from __future__ import print_function, absolute_import
from wendelin.wcfs.internal import xbtree from wendelin.wcfs.internal import xbtree
from BTrees.LOBTree import LOBTree, LOBucket from BTrees.LOBTree import LOBTree
from BTrees.IIBTree import IITreeSet, IISet from BTrees.IIBTree import IITreeSet, IISet
from BTrees.tests import testBTrees from BTrees.tests import testBTrees
from BTrees import check as zbcheck from BTrees import check as zbcheck
...@@ -41,7 +39,7 @@ T = xbtree.Tree ...@@ -41,7 +39,7 @@ T = xbtree.Tree
B = lambda *keyv: xbtree.Bucket(keyv, None) B = lambda *keyv: xbtree.Bucket(keyv, None)
Bv = lambda keyv, *valuev: xbtree.Bucket(keyv, valuev) Bv = lambda keyv, *valuev: xbtree.Bucket(keyv, valuev)
# build ztree with known degenerate topology, see: # buildDegenerateZTree builds ztree with known degenerate topology, see:
# https://github.com/zopefoundation/ZODB/commit/6cd24e99f89b # https://github.com/zopefoundation/ZODB/commit/6cd24e99f89b
# https://github.com/zopefoundation/BTrees/blob/4.7.2-1-g078ba60/BTrees/tests/testBTrees.py#L20 # https://github.com/zopefoundation/BTrees/blob/4.7.2-1-g078ba60/BTrees/tests/testBTrees.py#L20
def buildDegenerateZTree(): def buildDegenerateZTree():
...@@ -141,9 +139,7 @@ def test_allStructs(): ...@@ -141,9 +139,7 @@ def test_allStructs():
assert XY([1,3], 0, 0) == [ T([], B(1,3)) ] assert XY([1,3], 0, 0) == [ T([], B(1,3)) ]
assert X([], 0, 1) == [ T([], B()) ] # nothing to split (?) -> y assert XY([], 0, 1) == [ T([], B()) ] # nothing to split
#assert X([], 0, 1) == [ T([], B()), T([0], B(), B()) ]
assert Y([], 0, 1) == [ T([], B()) ]
assert X([], 1, 0) == [ T([], B()), assert X([], 1, 0) == [ T([], B()),
...@@ -492,7 +488,7 @@ def test_restructure(): ...@@ -492,7 +488,7 @@ def test_restructure():
return ztree return ztree
# R restructures ztree to have specified new topology. # R restructures ztree to have specified new topology.
# Unless dontcommit=Y is specified, the result is committed. # The result is committed unless dontcommit=Y specified.
def R(ztree, newtopo, dontcommit=False): def R(ztree, newtopo, dontcommit=False):
# verify ztree consistency # verify ztree consistency
items = list(ztree.items()) items = list(ztree.items())
...@@ -511,7 +507,7 @@ def test_restructure(): ...@@ -511,7 +507,7 @@ def test_restructure():
# force objects state to be reloaded from storage. # force objects state to be reloaded from storage.
# this leads further checks to also verify if Restructure modified a # this leads further checks to also verify if Restructure modified a
# node, but did not marked it as changed. If this bug is indeed there - # node, but did not marked it as changed. If this bug is indeed there -
# then the modifications will be lost on live cache clear. # then the modifications will be lost after live cache clearance.
zconn.cacheMinimize() zconn.cacheMinimize()
assert xbtree.StructureOf(ztree, onlyKeys=True) == \ assert xbtree.StructureOf(ztree, onlyKeys=True) == \
...@@ -523,10 +519,10 @@ def test_restructure(): ...@@ -523,10 +519,10 @@ def test_restructure():
for (k,v) in items: for (k,v) in items:
assert ztree[k] == v assert ztree[k] == v
# S returns topo-encoded keys-only structure of ztree # S returns topo-encoded keys-only structure of ztree.
# Sv returns topo-encoded structure of ztree with values.
def S(ztree): def S(ztree):
return xbtree.TopoEncode(xbtree.StructureOf(ztree, onlyKeys=True)) return xbtree.TopoEncode(xbtree.StructureOf(ztree, onlyKeys=True))
# Sv returns topo-encoded structure of ztree with values
def Sv(ztree): def Sv(ztree):
return xbtree.TopoEncode(xbtree.StructureOf(ztree), xencode) return xbtree.TopoEncode(xbtree.StructureOf(ztree), xencode)
...@@ -713,7 +709,7 @@ def test_restructure(): ...@@ -713,7 +709,7 @@ def test_restructure():
assertB(b8, 8) assertB(b8, 8)
# ---- new strucure given with values ---- # ---- new structure given with values ----
z = Z(0,2) z = Z(0,2)
R(z, T([1], Bv([0],X[0]), Bv([2],X[2]))) R(z, T([1], Bv([0],X[0]), Bv([2],X[2])))
b0, b2 = assertT(z, [1], 'B','B') b0, b2 = assertT(z, [1], 'B','B')
...@@ -738,7 +734,7 @@ def test_restructure(): ...@@ -738,7 +734,7 @@ def test_restructure():
R(z, 'T4/T2-T/T-T-T6,10/B1-B3-T-T-T/T-B7-B11/B5') R(z, 'T4/T2-T/T-T-T6,10/B1-B3-T-T-T/T-B7-B11/B5')
R(z, 'T/B1,3,5,7,11') R(z, 'T/B1,3,5,7,11')
# verify changed objects are marked as such and so included into commit # verify that changed objects are marked as such and so included into commit
# (just R also partly verifies this on every call) # (just R also partly verifies this on every call)
z = Z(0,2,3) z = Z(0,2,3)
transaction.commit() transaction.commit()
...@@ -793,7 +789,6 @@ def test_restructure(): ...@@ -793,7 +789,6 @@ def test_restructure():
# #
# ( we make sure that Restructure can make the restructurement and that # ( we make sure that Restructure can make the restructurement and that
# after restructure a tree remains valid without any error introduced ) # after restructure a tree remains valid without any error introduced )
for nkeys in range(5): # XXX !slow -> ↑ for nkeys in range(5): # XXX !slow -> ↑
for xkeyv in xbtree._iterSplitByN(-1, 5+1, nkeys): for xkeyv in xbtree._iterSplitByN(-1, 5+1, nkeys):
keyv = xkeyv[1:-1] # -1, ..., N -> ... keyv = xkeyv[1:-1] # -1, ..., N -> ...
...@@ -813,9 +808,24 @@ def test_restructure(): ...@@ -813,9 +808,24 @@ def test_restructure():
def test_walkBFS(): def test_walkBFS():
R = xbtree._Range R = xbtree._Range
# XXX ø # T/B
# XXX 1 k->v b = B()
t = T([], b)
walkv = list(xbtree.__walkBFS(t))
assert len(walkv) == 2 # (t) (b)
_ = walkv[0]
assert len(_) == 1
assert _[0].range == R(-inf, inf)
assert _[0].node is t
_ = walkv[1]
assert len(_) == 1
assert _[0].range == R(-inf, inf)
assert _[0].node is b
# T0/T-T/B-B
bl = B(); br = B() bl = B(); br = B()
tl = T([], bl) tl = T([], bl)
tr = T([], br) tr = T([], br)
...@@ -926,7 +936,6 @@ def test_zwalkBFS(): ...@@ -926,7 +936,6 @@ def test_zwalkBFS():
def test_keyvSliceBy(): def test_keyvSliceBy():
X = xbtree._keyvSliceBy X = xbtree._keyvSliceBy
assert X([], 0,0) == [] assert X([], 0,0) == []
......
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