Rev 18: Assert that the raw offsets are independent of the bloom size. in http://bzr.arbash-meinel.com/plugins/index2

John Arbash Meinel john at arbash-meinel.com
Wed Jul 2 17:12:08 BST 2008


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

------------------------------------------------------------
revno: 18
revision-id: john at arbash-meinel.com-20080702161204-uvj9yxiq464wngc0
parent: john at arbash-meinel.com-20080702160822-4q8qdi10120l1aen
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: index2
timestamp: Wed 2008-07-02 11:12:04 -0500
message:
  Assert that the raw offsets are independent of the bloom size.
-------------- next part --------------
=== modified file 'tests/test_btree_index.py'
--- a/tests/test_btree_index.py	2008-07-02 16:08:22 +0000
+++ b/tests/test_btree_index.py	2008-07-02 16:12:04 +0000
@@ -677,3 +677,24 @@
         self.assertTrue(node_bloom.contains_raw_offset(raw_offsets[('foo',)]))
         self.assertTrue(node_bloom.contains_raw_offset(raw_offsets[('bar',)]))
         self.assertFalse(node_bloom.contains_raw_offset(raw_offsets[('baz',)]))
+
+    def test_contains_raw_offsets_mixed_sizes(self):
+        small_bloom = BloomSHA1(16 * 8)
+        small_bloom.insert('foo')
+        small_bloom.insert('bar')
+        big_bloom = BloomSHA1(256 * 8)
+        big_bloom.insert('foo')
+        big_bloom.insert('bar')
+
+        small_node_bloom = btree_index.NodeBloom(small_bloom._array.tostring())
+        keys = [('foo',), ('bar',), ('baz',)]
+        raw_offsets = small_node_bloom.get_raw_offsets(keys)
+        big_node_bloom = btree_index.NodeBloom(big_bloom._array.tostring())
+        self.assertEqual(raw_offsets, big_node_bloom.get_raw_offsets(keys))
+
+        self.assertTrue(small_node_bloom.contains_raw_offset(raw_offsets[('foo',)]))
+        self.assertTrue(small_node_bloom.contains_raw_offset(raw_offsets[('bar',)]))
+        self.assertFalse(small_node_bloom.contains_raw_offset(raw_offsets[('baz',)]))
+        self.assertTrue(big_node_bloom.contains_raw_offset(raw_offsets[('foo',)]))
+        self.assertTrue(big_node_bloom.contains_raw_offset(raw_offsets[('bar',)]))
+        self.assertFalse(big_node_bloom.contains_raw_offset(raw_offsets[('baz',)]))



More information about the bazaar-commits mailing list