Rev 14: move _use_blooms to a member variable to make the tests independent of default settings in http://bzr.arbash-meinel.com/plugins/index2

John Arbash Meinel john at arbash-meinel.com
Wed Jul 2 15:50:05 BST 2008


At http://bzr.arbash-meinel.com/plugins/index2

------------------------------------------------------------
revno: 14
revision-id: john at arbash-meinel.com-20080702145001-vz3rohjcio2226cb
parent: john at arbash-meinel.com-20080702144538-m492wdmmu7li4ceq
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: index2
timestamp: Wed 2008-07-02 09:50:01 -0500
message:
  move _use_blooms to a member variable to make the tests independent of default settings
-------------- next part --------------
=== modified file 'btree_index.py'
--- a/btree_index.py	2008-07-02 14:45:38 +0000
+++ b/btree_index.py	2008-07-02 14:50:01 +0000
@@ -39,7 +39,6 @@
 _PAGE_SIZE = 4096
 
 bloom_hits = 0
-use_blooms = True
 
 
 class NodeBloom(BloomSHA1):
@@ -333,6 +332,8 @@
     memory except when very large walks are done.
     """
 
+    _default_use_blooms = False
+
     def __init__(self, transport, name, size=None):
         """Create a B+Tree index object on the index name.
 
@@ -350,6 +351,7 @@
         self._page_size = transport.recommended_page_size()
         self._node_cache = lru_cache.LRUCache()
         self._key_count = None
+        self._use_blooms = BTreeGraphIndex._default_use_blooms
 
     def __eq__(self, other):
         """Equal when self and other were created with the same parameters."""
@@ -586,7 +588,6 @@
             return
         nodes_and_keys = [(0, keys)]
         row_offset = 0
-        _use_bloom = use_blooms
         for row_length in self._row_lengths[:-1]:
             node_indexes = [idx for idx, s_keys in nodes_and_keys]
             nodes = self._get_nodes(node_indexes)
@@ -596,7 +597,7 @@
             next_nodes_and_keys = []
             for node_index, sub_keys in nodes_and_keys:
                 node = nodes[node_index]
-                if _use_bloom and node.bloom is not None:
+                if self._use_blooms and node.bloom is not None:
                     # If using blooms, filter out any nodes that don't hit.
                     remaining_sub_keys = [sub_key for sub_key in sub_keys
                                           if '\x00'.join(sub_key) in node.bloom]

=== modified file 'tests/test_btree_index.py'
--- a/tests/test_btree_index.py	2008-07-02 14:45:38 +0000
+++ b/tests/test_btree_index.py	2008-07-02 14:50:01 +0000
@@ -483,6 +483,8 @@
         index = btree_index.BTreeGraphIndex(transport, 'index', size)
         del transport._activity[:]
         self.assertEqual([], transport._activity)
+        # Make sure bloom checking is activated
+        index._use_blooms = True
         # search for one key
         found_nodes = list(index.iter_entries([("foo",)]))
         self.assertEqual([], found_nodes)



More information about the bazaar-commits mailing list