Rev 3759: Test unmapping with one child left but multiple keys. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Wed Nov 12 00:47:09 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 3759
revision-id: robertc at robertcollins.net-20081112004705-qukvf63rrvqk89lh
parent: robertc at robertcollins.net-20081111100253-hx2ndctrnwilr62i
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Wed 2008-11-12 11:47:05 +1100
message:
Test unmapping with one child left but multiple keys.
modified:
bzrlib/chk_map.py chk_map.py-20081001014447-ue6kkuhofvdecvxa-1
bzrlib/tests/test_chk_map.py test_chk_map.py-20081001014447-ue6kkuhofvdecvxa-2
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py 2008-11-11 06:02:49 +0000
+++ b/bzrlib/chk_map.py 2008-11-12 00:47:05 +0000
@@ -634,26 +634,10 @@
else:
# Stash the returned node
self._items[serialised_key] = unmapped
- if len(self) == 1:
+ if len(self._items) == 1:
# this node is no longer needed:
return self._items.values()[0]
return self
- prefix, node_details = child.map(store, key, value)
- if len(node_details) == 1:
- # child may have shrunk, or might be the same.
- self._len = self._len - old_len + len(child)
- self._items[serialised_key] = child
- return self.unique_serialised_prefix(), [("", self)]
- # child has overflown - create a new intermediate node.
- # XXX: This is where we might want to try and expand our depth
- # to refer to more bytes of every child (which would give us
- # multiple pointers to child nodes, but less intermediate nodes)
- child = self._new_child(serialised_key, InternalNode)
- for split, node in node_details:
- child.add_node(split, node)
- self._len = self._len - old_len + len(child)
- return self.unique_serialised_prefix(), [("", self)]
-
class RootNode(Node):
=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py 2008-11-11 06:02:49 +0000
+++ b/bzrlib/tests/test_chk_map.py 2008-11-12 00:47:05 +0000
@@ -749,6 +749,20 @@
self.assertEqual([keys[-1]], keys)
self.assertEqual(('sha1:d3f06fc03d8f50845894d8d04cc5a3f47e62948d',), keys[-1])
+ def test_unmap_k1_from_k1_k22_k23_gives_k22_k23_tree_new(self):
+ chkmap = self._get_map(
+ {('k1',):'foo', ('k22',):'bar', ('k23',): 'quux'}, maximum_size=10)
+ # Check we have the expected tree.
+ self.assertEqual(('sha1:d68cd97c95e847d3dc58c05537aa5fdcdf2cf5da',),
+ chkmap._root_node)
+ chkmap._ensure_root()
+ node = chkmap._root_node
+ k2_ptr = node._items['k2']
+ # unmapping k21 should give us a root, with k22 and k23 as direct
+ # children, and should not have needed to page in the subtree.
+ result = node.unmap(chkmap._store, ('k1',))
+ self.assertEqual(k2_ptr, result)
+
def test_unmap_second_last_shrinks_to_other_branch(self):
# unmapping the second last child of an internal node downgrades it to
# a leaf node.
More information about the bazaar-commits
mailing list