Rev 66: Make BTree indices be used by default. in http://people.ubuntu.com/~robertc/baz2.0/plugins/search/trunk
Robert Collins
robertc at robertcollins.net
Tue Dec 2 22:36:43 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/plugins/search/trunk
------------------------------------------------------------
revno: 66
revision-id: robertc at robertcollins.net-20081202223633-et3bqd5i8d3qnu94
parent: robertc at robertcollins.net-20081202221109-n1tfmvm3aa9d3jpu
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Wed 2008-12-03 09:36:33 +1100
message:
Make BTree indices be used by default.
modified:
NEWS news-20080608052041-z5bahsl8kwl0uf4x-2
index.py index.py-20080608055509-hnimeek7q8tctkqf-2
tests/test_index.py test_index.py-20080608055509-hnimeek7q8tctkqf-4
=== modified file 'NEWS'
--- a/NEWS 2008-11-16 23:01:04 +0000
+++ b/NEWS 2008-12-02 22:36:33 +0000
@@ -14,6 +14,11 @@
* Requires bzr.dev with the log filtering patch for full functionality.
users not using bzr 1.6b3 or later. (Robert Collins)
+ * New index format '2' used by default, which uses BTree indices. This
+ adds a dependency on bzrlib 1.7 for the BTree support code. To upgrade
+ a search index, remove the .bzr/bzr-search folder and reindex.
+ (Robert Collins)
+
FEATURES:
* ``bzr log -m`` will now use a search index for message searches that
=== modified file 'index.py'
--- a/index.py 2008-12-02 22:11:09 +0000
+++ b/index.py 2008-12-02 22:36:33 +0000
@@ -85,7 +85,7 @@
_tokeniser_re = re.compile("[^A-Za-z0-9_]")
-def init_index(branch, format_number=1):
+def init_index(branch, format_number=2):
"""Initialise an index on branch.
:param format_number: The index format to create. Currently 1 by default.
@@ -1388,13 +1388,13 @@
node_indices = set([low_index, high_index])
nodes = self._get_internal_nodes(node_indices)
low_node = nodes[low_index]
- positions = self._multi_bisect_right([lower_key], node.keys)
- node_offset = next_row_start + node.offset
- low_index = node_offset + positions[0]
+ positions = self._multi_bisect_right([lower_key], low_node.keys)
+ node_offset = next_row_start + low_node.offset
+ low_index = node_offset + positions[0][0]
high_node = nodes[high_index]
- positions = self._multi_bisect_right([higher_key], node.keys)
- node_offset = next_row_start + node.offset
- high_index = node_offset + positions[0]
+ positions = self._multi_bisect_right([higher_key], high_node.keys)
+ node_offset = next_row_start + high_node.offset
+ high_index = node_offset + positions[0][0]
# We should now be at the _LeafNodes
node_indices = range(low_index, high_index + 1)
@@ -1521,5 +1521,5 @@
_FORMATS = {
# format: index builder, index reader, index deletes
_FORMAT_1:(InMemoryGraphIndex, SuggestableGraphIndex, False),
- _FORMAT_2:(BTreeBuilder, BTreeGraphIndex, True)
+ _FORMAT_2:(BTreeBuilder, SuggestableBTreeGraphIndex, True)
}
=== modified file 'tests/test_index.py'
--- a/tests/test_index.py 2008-12-02 22:11:09 +0000
+++ b/tests/test_index.py 2008-12-02 22:36:33 +0000
@@ -62,9 +62,9 @@
# We expect two files:
# - format, containing 'bzr-search search folder 1\n'
# - a names file, which is an empty GraphIndex
- self.assertEqual('bzr-search search folder 1\n',
+ self.assertEqual('bzr-search search folder 2\n',
transport.get_bytes('format'))
- names_list = GraphIndex(transport, 'names', None)
+ names_list = BTreeGraphIndex(transport, 'names', None)
self.assertEqual([], list(names_list.iter_all_entries()))
# And a number of empty directories
self.assertTrue(transport.has('obsolete'))
More information about the bazaar-commits
mailing list