Rev 4505: We should not enqueue the same uninteresting node when it is in http://bazaar.launchpad.net/~jameinel/bzr/1.17-chk-multilevel

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


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

------------------------------------------------------------
revno: 4505
revision-id: john at arbash-meinel.com-20090630144535-0wc7tiu3y8nfv32g
parent: john at arbash-meinel.com-20090630143526-uvgs0ntn387t5c7j
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-chk-multilevel
timestamp: Tue 2009-06-30 09:45:35 -0500
message:
  We should not enqueue the same uninteresting node when it is
  referenced by more than one uninteresting root.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2009-06-30 14:35:26 +0000
+++ b/bzrlib/chk_map.py	2009-06-30 14:45:35 +0000
@@ -1470,12 +1470,14 @@
         for record, node, prefix_refs, items in \
             self._read_nodes_from_store(self._uninteresting_root_keys):
             # Uninteresting node
-            self._all_uninteresting_chks.update([k for _,k in prefix_refs])
+            new_refs = [p_k for p_k in prefix_refs
+                             if p_k[1] not in self._all_uninteresting_chks]
+            self._all_uninteresting_chks.update([k for _,k in new_refs])
             self._all_uninteresting_items.update(items)
             # Queue up the uninteresting references
             # Don't actually put them in the 'to-read' queue until we have
             # finished checking the interesting references
-            uninteresting_chks_to_enqueue.extend(prefix_refs)
+            uninteresting_chks_to_enqueue.extend(new_refs)
         # filter out any root keys that are already known to be uninteresting
         interesting_keys = set(self._interesting_root_keys).difference(
                                 self._all_uninteresting_chks)
@@ -1562,11 +1564,14 @@
                     interesting.append((prefix, None, ref))
 
     def _process_next_uninteresting(self):
+        # TODO: We really should be filtering uninteresting requests a bit more
         prefix, ref = heapq.heappop(self._uninteresting_queue)
         for record, node, prefix_refs, items in \
                 self._read_nodes_from_store([ref]):
             self._all_uninteresting_items.update(items)
             for prefix, ref in prefix_refs:
+                # if ref in self._all_uninteresting_chks:
+                #     continue
                 self._all_uninteresting_chks.add(ref)
                 heapq.heappush(self._uninteresting_queue, (prefix, ref))
 

=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py	2009-06-30 14:35:26 +0000
+++ b/bzrlib/tests/test_chk_map.py	2009-06-30 14:45:35 +0000
@@ -2419,6 +2419,27 @@
         self.assertEqual(sorted([('', None, key1), ('', None, key2)]),
                          sorted(iterator._interesting_queue))
 
+    def test__read_all_roots_multiple_uninteresting(self):
+        c_map = self.make_two_deep_map()
+        key1 = c_map.key()
+        c_map._dump_tree() # load everything
+        key1_a = c_map._root_node._items['a'].key()
+        c_map.map(('ccc',), 'new ccc value')
+        key2 = c_map._save()
+        key2_a = c_map._root_node._items['a'].key()
+        c_map.map(('add',), 'new add value')
+        key3 = c_map._save()
+        key3_a = c_map._root_node._items['a'].key()
+        iterator = self.get_iterator([key3], [key1, key2],
+                                     chk_map._search_key_plain)
+        root_results = [record.key for record in iterator._read_all_roots()]
+        self.assertEqual([key3], root_results)
+        # the 'a' keys should not be queued up 2 times, since they are
+        # identical
+        self.assertEqual([('a', key1_a)],
+                         iterator._uninteresting_queue)
+        self.assertEqual([('a', None, key3_a)], iterator._interesting_queue)
+
 
 class TestIterInterestingNodes(TestCaseWithExampleMaps):
 



More information about the bazaar-commits mailing list