Rev 4504: Add the shortcut path for _read_all_roots. in http://bazaar.launchpad.net/~jameinel/bzr/1.17-chk-multilevel

John Arbash Meinel john at arbash-meinel.com
Tue Jun 30 15:35:57 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/1.17-chk-multilevel

------------------------------------------------------------
revno: 4504
revision-id: john at arbash-meinel.com-20090630143526-uvgs0ntn387t5c7j
parent: john at arbash-meinel.com-20090630141954-fnjeh1raggvz3j4q
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-chk-multilevel
timestamp: Tue 2009-06-30 09:35:26 -0500
message:
  Add the shortcut path for _read_all_roots.
  
  Now we have a shortcut for reading and a shortcut for yielding.
  We just need to get the standard case optimized, now.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2009-06-30 14:19:54 +0000
+++ b/bzrlib/chk_map.py	2009-06-30 14:35:26 +0000
@@ -1419,6 +1419,7 @@
         self._all_uninteresting_chks = set(self._uninteresting_root_keys)
         self._all_uninteresting_items = set()
         self._interesting_queued_refs = set()
+        # TODO: use this or delete it
         self._interesting_queued_items = set()
         self._search_key_func = search_key_func
 
@@ -1459,7 +1460,9 @@
         if not self._uninteresting_root_keys:
             # TODO: when there are no _uninteresting_root_keys we can shortcut
             # a lot of the code
-            pass
+            self._interesting_queue = [('', None, key) for key
+                                       in self._interesting_root_keys]
+            return
         # Read the uninteresting nodes first, we would like to read them
         # simultaneously, but that requires buffering the interesting nodes
         # until all uninteresting ones have been read

=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py	2009-06-30 14:18:11 +0000
+++ b/bzrlib/tests/test_chk_map.py	2009-06-30 14:35:26 +0000
@@ -2378,6 +2378,46 @@
                                  ('d', None, key2_d)]),
                          sorted(iterator._interesting_queue))
 
+    def test__read_all_roots_no_uninteresting(self):
+        # This is the 'initial branch' case. With nothing in the uninteresting
+        # set, we can just queue up all root nodes into interesting queue, and
+        # then have them fast-path flushed via _flush_interesting_queue
+        c_map = self.make_two_deep_map()
+        key1 = c_map.key()
+        iterator = self.get_iterator([key1], [], chk_map._search_key_plain)
+        root_results = [record.key for record in iterator._read_all_roots()]
+        self.assertEqual([], root_results)
+        self.assertEqual([], iterator._uninteresting_queue)
+        self.assertEqual([('', None, key1)], iterator._interesting_queue)
+
+        c_map2 = self.make_one_deep_map()
+        key2 = c_map2.key()
+        iterator = self.get_iterator([key1, key2], [],
+                                     chk_map._search_key_plain)
+        root_results = [record.key for record in iterator._read_all_roots()]
+        self.assertEqual([], root_results)
+        self.assertEqual([], iterator._uninteresting_queue)
+        self.assertEqual(sorted([('', None, key1), ('', None, key2)]),
+                         sorted(iterator._interesting_queue))
+
+    def test__read_all_roots_no_uninteresting_16(self):
+        c_map = self.make_two_deep_map(chk_map._search_key_16)
+        key1 = c_map.key()
+        iterator = self.get_iterator([key1], [], chk_map._search_key_16)
+        root_results = [record.key for record in iterator._read_all_roots()]
+        self.assertEqual([], root_results)
+        self.assertEqual([], iterator._uninteresting_queue)
+        self.assertEqual([('', None, key1)], iterator._interesting_queue)
+
+        c_map2 = self.make_one_deep_map(chk_map._search_key_16)
+        key2 = c_map2.key()
+        iterator = self.get_iterator([key1, key2], [],
+                                     chk_map._search_key_16)
+        root_results = [record.key for record in iterator._read_all_roots()]
+        self.assertEqual([], root_results)
+        self.assertEqual([], iterator._uninteresting_queue)
+        self.assertEqual(sorted([('', None, key1), ('', None, key2)]),
+                         sorted(iterator._interesting_queue))
 
 
 class TestIterInterestingNodes(TestCaseWithExampleMaps):



More information about the bazaar-commits mailing list