Rev 17: Various tweaks in bloom usage. in http://people.ubuntu.com/~robertc/baz2.0/plugins/index2/trunk

Robert Collins robertc at robertcollins.net
Wed Jul 2 23:02:45 BST 2008


At http://people.ubuntu.com/~robertc/baz2.0/plugins/index2/trunk

------------------------------------------------------------
revno: 17
revision-id: robertc at robertcollins.net-20080702220240-73x9ykl98pqpg8by
parent: robertc at robertcollins.net-20080702125159-o72w19dm8g5yrtt0
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Thu 2008-07-03 08:02:40 +1000
message:
  Various tweaks in bloom usage.
modified:
  btree_index.py                 index.py-20080624222253-p0x5f92uyh5hw734-7
=== modified file 'btree_index.py'
--- a/btree_index.py	2008-07-02 12:51:59 +0000
+++ b/btree_index.py	2008-07-02 22:02:40 +0000
@@ -39,7 +39,7 @@
 _PAGE_SIZE = 4096
 
 bloom_hits = 0
-use_blooms = False
+use_blooms = True
 
 class NodeBloom(BloomSHA1):
     """Subclass of BloomSHA1 that can be read from a file."""
@@ -174,6 +174,8 @@
                             internal_row.writer.write(_INTERNAL_FLAG)
                             internal_row.writer.write(_INTERNAL_OFFSET +
                                 str(self.rows[pos + 1].nodes) + "\n")
+                            # new bloom for the new node
+                            internal_row.bloom = BloomSHA1(256 * 8)
                     # add a new leaf
                     length = _PAGE_SIZE
                     if self.rows[-1].nodes == 0:
@@ -436,6 +438,8 @@
         keys = frozenset(keys)
         if not keys:
             return
+        # in a two-row index, row 0 has the filter.
+        bloom_row = len(self._row_lengths) - 2
         for key in keys:
             # repeated single-bisection : 'make it work'
             # FUTURE: look within the current node for the next key,
@@ -450,7 +454,7 @@
             offset = self._row_lengths[row]
             string_key = '\x00'.join(key)
             while type(node) != _LeafNode:
-                if use_blooms and node.bloom is not None:
+                if use_blooms and row == bloom_row and node.bloom is not None:
                     if string_key not in node.bloom:
                         global bloom_hits
                         bloom_hits += 1




More information about the bazaar-commits mailing list