Rev 5493: Do some more offset testing, etc in http://bazaar.launchpad.net/~jameinel/bzr/2.3-gcb-peak-mem

John Arbash Meinel john at arbash-meinel.com
Mon Oct 18 22:18:19 BST 2010


At http://bazaar.launchpad.net/~jameinel/bzr/2.3-gcb-peak-mem

------------------------------------------------------------
revno: 5493
revision-id: john at arbash-meinel.com-20101018211803-e88mvx0f2serp0nd
parent: john at arbash-meinel.com-20101014214602-x3o61jymo86qduj7
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.3-gcb-peak-mem
timestamp: Mon 2010-10-18 16:18:03 -0500
message:
  Do some more offset testing, etc
-------------- next part --------------
=== modified file 'bzrlib/_delta_index_pyx.pyx'
--- a/bzrlib/_delta_index_pyx.pyx	2010-10-14 21:46:02 +0000
+++ b/bzrlib/_delta_index_pyx.pyx	2010-10-18 21:18:03 +0000
@@ -88,6 +88,8 @@
     def __init__(self):
         self.hash_mask = 0
         self.buckets = [None]
+        # Just initialize the basic buckets to start with
+        self._ensure_enough_buckets(0)
         self.num_entries = 0
         self.sources = []
 
@@ -142,6 +144,23 @@
     cdef _add_offset(self, rabin_offset offset):
         self._add_offset_to_buckets(self.buckets, self.hash_mask, offset)
 
+    def _py_add_offset(self, val, source):
+        """A python thunk for testing _add_offset
+
+        :param val: The Rabin hash value (integer)
+        :param source: The source index (integer)
+        :return: A newly created rabin_offset that has been created and added
+        """
+        cdef rabin_offset offset
+
+        offset = rabin_offset()
+        offset.next = None
+        offset.val = val
+        offset.source = source
+        offset.ptr = NULL
+        self._add_offset(offset)
+        return offset
+
     def _ensure_enough_buckets(self, new_size):
         """Make sure we have enough buckets ready."""
         cdef long num_buckets

=== modified file 'bzrlib/tests/test__delta_index.py'
--- a/bzrlib/tests/test__delta_index.py	2010-10-14 21:46:02 +0000
+++ b/bzrlib/tests/test__delta_index.py	2010-10-18 21:18:03 +0000
@@ -185,3 +185,8 @@
         self.assertEqual(1, bucket.count)
         self.assertEqual([None], self.index.buckets[:1])
         self.assertEqual([None]*14, self.index.buckets[2:])
+
+
+class TestRabinIndex_add_offset(TestCaseWithRabinIndex):
+
+    def test_add_offset_simple(self):



More information about the bazaar-commits mailing list