Rev 4665: If we are going to sometimes use a dict, we have to conform to just the dict interface. in http://bazaar.launchpad.net/~jameinel/bzr/2.0-cache-cix

John Arbash Meinel john at arbash-meinel.com
Wed Sep 9 20:32:41 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.0-cache-cix

------------------------------------------------------------
revno: 4665
revision-id: john at arbash-meinel.com-20090909193227-fd07kyduo1ty0d81
parent: john at arbash-meinel.com-20090909185256-rdaxy872xauoem46
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.0-cache-cix
timestamp: Wed 2009-09-09 14:32:27 -0500
message:
  If we are going to sometimes use a dict, we have to conform to just the dict interface.
  
  We were using Cache.add() when really we can just use Cache[foo] = bar
-------------- next part --------------
=== modified file 'bzrlib/btree_index.py'
--- a/bzrlib/btree_index.py	2009-09-09 18:52:56 +0000
+++ b/bzrlib/btree_index.py	2009-09-09 19:32:27 +0000
@@ -696,9 +696,9 @@
                 if start_of_leaves is None:
                     start_of_leaves = self._row_offsets[-2]
                 if node_pos < start_of_leaves:
-                    self._internal_node_cache.add(node_pos, node)
+                    self._internal_node_cache[node_pos] = node
                 else:
-                    self._leaf_node_cache.add(node_pos, node)
+                    self._leaf_node_cache[node_pos] = node
             found[node_pos] = node
         return found
 

=== modified file 'bzrlib/tests/test_btree_index.py'
--- a/bzrlib/tests/test_btree_index.py	2009-09-09 18:52:56 +0000
+++ b/bzrlib/tests/test_btree_index.py	2009-09-09 19:32:27 +0000
@@ -1119,6 +1119,9 @@
 
     def test_supports_unlimited_cache(self):
         builder = btree_index.BTreeBuilder(reference_lists=0, key_elements=1)
+        nodes = self.make_nodes(500, 1, 0)
+        for node in nodes:
+            builder.add_node(*node)
         stream = builder.finish()
         trans = get_transport(self.get_url())
         size = trans.put_file('index', stream)
@@ -1140,6 +1143,7 @@
                                             unlimited_cache=True)
         self.assertIsInstance(index._leaf_node_cache, dict)
         self.assertIs(type(index._internal_node_cache), dict)
+        entries = set(index.iter_entries([nodes[0][1], nodes[300][0]]))
 
 
 class TestBTreeNodes(BTreeTestCase):



More information about the bazaar-commits mailing list