Rev 3529: Quick hack to expose the _iter_sorted_entries at a higher level in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/btree_alt
John Arbash Meinel
john at arbash-meinel.com
Tue Jul 8 03:29:45 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/btree_alt
------------------------------------------------------------
revno: 3529
revision-id: john at arbash-meinel.com-20080708022939-fgry0pjpooypuhe9
parent: pqm at pqm.ubuntu.com-20080707151531-ra9moj8zrk9tiw2a
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: btree_alt
timestamp: Mon 2008-07-07 21:29:39 -0500
message:
Quick hack to expose the _iter_sorted_entries at a higher level
modified:
bzrlib/index.py index.py-20070712131115-lolkarso50vjr64s-1
-------------- next part --------------
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py 2008-06-17 09:32:08 +0000
+++ b/bzrlib/index.py 2008-07-08 02:29:39 +0000
@@ -1072,13 +1072,43 @@
defined order for the result iteration - it will be in the most
efficient order for the index.
"""
- keys = set(keys)
+ has_sorted_iter = True
for index in self._indices:
+ if getattr(index, '_iter_sorted_entries', None) is None:
+ has_sorted_iter = False
+ break
+
+ if has_sorted_iter:
if not keys:
return
- for node in index.iter_entries(keys):
- keys.remove(node[1])
- yield node
+ from bzrlib.plugins.index2 import btree_index
+ # We would like to deduplicate the keys, can we do it without
+ # having to loop tons of times?
+ keys = sorted(keys)
+ raw_offsets = None
+ for index in self._indices:
+ if not keys:
+ return
+ missing_keys = []
+ if (raw_offsets is None
+ and index._get_global_bloom() is not None):
+ raw_offsets = btree_index.NodeBloom.get_raw_offsets(keys)
+ for present, node in index._iter_sorted_entries(keys,
+ raw_offsets or {},
+ {}):
+ if present:
+ yield node
+ else:
+ missing_keys.append(node)
+ keys = missing_keys
+ else:
+ keys = set(keys)
+ for index in self._indices:
+ if not keys:
+ return
+ for node in index.iter_entries(keys):
+ keys.remove(node[1])
+ yield node
def iter_entries_prefix(self, keys):
"""Iterate over keys within the index using prefix matching.
More information about the bazaar-commits
mailing list