Commit 8d90dfb2 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 70da0a60
......@@ -21,7 +21,7 @@
"""Package xbtree provides utilities for inspecting/manipulating internal
structure of integer-keyed BTrees.
It is primarily used to verify ΔBTail in wcfs.
It is primarily used to help verify ΔBTail in wcfs.
- `Tree` represents a tree node.
- `Bucket` represents a bucket node.
......@@ -91,7 +91,7 @@ in left-to-right order.
Visualization
-------------
The following visualization utilities are provided to help understanding BTrees
The following visualization utilities are provided to help understand BTrees
better:
- `topoview` displays BTree structure given its topology-encoded representation.
......@@ -158,7 +158,6 @@ class Tree(object):
return s
__repr__ = __str__
# copy returns a deep copy of the tree.
# if onlyKeys=Y buckets in returned tree will contain only keys not values.
def copy(t, onlyKeys=False):
......@@ -285,7 +284,7 @@ def Restructure(ztree, newStructure):
zcheck(ztree) # verify ztree before our tweaks
# dict with all k->v from ztree
# {} with all k->v from ztree
kv = dict(ztree)
# walk original and new structures level by level.
......@@ -333,7 +332,6 @@ def Restructure(ztree, newStructure):
assert abs(v) < 1E3
return v
def d2(x,y):
#return abs(fin(x)-fin(y))
return (fin(x)-fin(y))**2
return d2(a.range.klo, b.range.klo) + \
d2(a.range.khi, b.range.khi)
......@@ -349,8 +347,8 @@ def Restructure(ztree, newStructure):
# find the assignments.
# TODO try to avoid scipy dependency; we could also probably make
# assignments more efficiently taking into account that Av and Bv are
# key↑ and the property of D function so that if B2 > B1 (all keys in
# B2 > all keys in B1) and A < B1.hi, then D(B2, A) > D(B1, A).
# key↑ and the property of D function is so that if B2 > B1 (all keys
# in B2 > all keys in B1) and A < B1.hi, then D(B2, A) > D(B1, A).
jv, iv = scipy.optimize.linear_sum_assignment(C)
for (j,i) in zip(jv, iv):
RNv[j].node.Z = RZv[i].node
......@@ -381,7 +379,7 @@ def Restructure(ztree, newStructure):
zrlevelv = list(__zwalkBFS(ztree)) # [] of _NodeInRange
rlevelv = list( __walkBFS(tnew)) # [] of _NodeInRange
# associate every non-bucket node in tnew to a znode
# associate every non-bucket node in tnew to a znode,
# extract bucket nodes.
zrbucketv = [] # of _NodeInRange
rbucketv = [] # of _NodeInRange
......@@ -818,7 +816,10 @@ def TopoEncode(tree, vencode=lambda v: '%d' % v):
assert ',' not in vtxt
assert '-' not in vtxt
vtxtv.append(vtxt)
vencoded[vtxt] = v
if vtxt in vencoded:
assert vencoded[vtxt] == v
else:
vencoded[vtxt] = v
tnode += ','.join(['%d:%s' % (k,vtxt)
for (k,vtxt) in zip(node.keyv, vtxtv)])
else:
......@@ -843,7 +844,7 @@ class TopoDecodeError(Exception):
pass
def TopoDecode(text, vdecode=int):
levelv = text.split('/') # T3/T-T/B1:a-T5/B-B7,8,9 -> T3 T-T B1:a-T5 B-B7,8,9
# XXX forbid mixing buckets-with-value with buckets-without-value?
# NOTE we don't forbid mixing buckets-with-value with buckets-without-value
# build nodes from bottom-up
currentv = [] # of nodes on current level (that we are building)
......
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