Rev 3796: Ensure that unmap() work even when the LeafNode isn't empty. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/chk_map

John Arbash Meinel john at arbash-meinel.com
Tue Dec 2 18:57:39 GMT 2008


At http://bzr.arbash-meinel.com/branches/bzr/brisbane/chk_map

------------------------------------------------------------
revno: 3796
revision-id: john at arbash-meinel.com-20081202185728-tt9nrap4t9fx97p2
parent: john at arbash-meinel.com-20081202184452-830u3t32hjagsk1y
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: chk_map
timestamp: Tue 2008-12-02 12:57:28 -0600
message:
  Ensure that unmap() work even when the LeafNode isn't empty.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2008-12-02 18:39:02 +0000
+++ b/bzrlib/chk_map.py	2008-12-02 18:57:28 +0000
@@ -879,7 +879,6 @@
         #    InternalNode, we don't have to check further.
         if isinstance(unmapped, InternalNode):
             return self
-        node = self._check_remap(store)
         return self._check_remap(store)
 
     def _check_remap(self, store):

=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py	2008-12-02 18:44:52 +0000
+++ b/bzrlib/tests/test_chk_map.py	2008-12-02 18:57:28 +0000
@@ -361,15 +361,17 @@
     def test_stable_unmap_double_deep(self):
         store = self.get_chk_bytes()
         chkmap = CHKMap(store, None)
-        # Should fit 2 keys per LeafNode
-        chkmap._root_node.set_maximum_size(30)
+        # Should fit 3 keys per LeafNode
+        chkmap._root_node.set_maximum_size(40)
         chkmap.map(('aaa',), 'v')
+        chkmap.map(('aaab',), 'v')
         chkmap.map(('aab',), 'very long value')
         chkmap.map(('abc',), 'v')
         self.assertEqualDiff("'' InternalNode None\n"
                              "  'aa' InternalNode None\n"
                              "    'aaa' LeafNode None\n"
                              "      ('aaa',) 'v'\n"
+                             "      ('aaab',) 'v'\n"
                              "    'aab' LeafNode None\n"
                              "      ('aab',) 'very long value'\n"
                              "  'ab' LeafNode None\n"
@@ -380,6 +382,35 @@
         chkmap.unmap(('aab',))
         self.assertEqualDiff("'' LeafNode None\n"
                              "      ('aaa',) 'v'\n"
+                             "      ('aaab',) 'v'\n"
+                             "      ('abc',) 'v'",
+                             chkmap._dump_tree())
+
+    def test_unmap_double_deep_non_empty_leaf(self):
+        store = self.get_chk_bytes()
+        chkmap = CHKMap(store, None)
+        # Should fit 3 keys per LeafNode
+        chkmap._root_node.set_maximum_size(40)
+        chkmap.map(('aaa',), 'v')
+        chkmap.map(('aab',), 'long value')
+        chkmap.map(('aabb',), 'v')
+        chkmap.map(('abc',), 'v')
+        self.assertEqualDiff("'' InternalNode None\n"
+                             "  'aa' InternalNode None\n"
+                             "    'aaa' LeafNode None\n"
+                             "      ('aaa',) 'v'\n"
+                             "    'aab' LeafNode None\n"
+                             "      ('aab',) 'long value'\n"
+                             "      ('aabb',) 'v'\n"
+                             "  'ab' LeafNode None\n"
+                             "      ('abc',) 'v'",
+                             chkmap._dump_tree())
+        # Removing the 'aab' key should cause everything to collapse back to a
+        # single node
+        chkmap.unmap(('aab',))
+        self.assertEqualDiff("'' LeafNode None\n"
+                             "      ('aaa',) 'v'\n"
+                             "      ('aabb',) 'v'\n"
                              "      ('abc',) 'v'",
                              chkmap._dump_tree())
 



More information about the bazaar-commits mailing list