Rev 4751: Add .clear_cache() members to GraphIndexBuilder and BTreeBuilder. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-peak-mem-tweak
John Arbash Meinel
john at arbash-meinel.com
Mon Oct 19 16:45:16 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/2.1-peak-mem-tweak
------------------------------------------------------------
revno: 4751
revision-id: john at arbash-meinel.com-20091019154510-tr02ifha84pmo3zh
parent: john at arbash-meinel.com-20091019153925-pkvnaoho6a2aawj7
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-peak-mem-tweak
timestamp: Mon 2009-10-19 10:45:10 -0500
message:
Add .clear_cache() members to GraphIndexBuilder and BTreeBuilder.
Update GroupCompressVersionedFiles.clear_cache() to clear the graph index's caches.
-------------- next part --------------
=== modified file 'bzrlib/groupcompress.py'
--- a/bzrlib/groupcompress.py 2009-10-19 15:06:58 +0000
+++ b/bzrlib/groupcompress.py 2009-10-19 15:45:10 +0000
@@ -1268,6 +1268,7 @@
def clear_cache(self):
"""See VersionedFiles.clear_cache()"""
self._group_cache.clear()
+ self._index._graph_index.clear_cache()
def _check_add(self, key, lines, random_id, check_content):
"""check that version_id and lines are safe to add."""
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py 2009-10-19 15:39:25 +0000
+++ b/bzrlib/index.py 2009-10-19 15:45:10 +0000
@@ -232,6 +232,13 @@
if self._nodes_by_key is not None and self._key_length > 1:
self._update_nodes_by_key(key, value, node_refs)
+ def clear_cache(self):
+ """See GraphIndex.clear_cache()
+
+ This is a no-op, but we need the api to conform to a generic 'Index'
+ abstraction.
+ """
+
def finish(self):
lines = [_SIGNATURE]
lines.append(_OPTION_NODE_REFS + str(self.reference_lists) + '\n')
=== modified file 'bzrlib/tests/test_btree_index.py'
--- a/bzrlib/tests/test_btree_index.py 2009-10-19 15:39:25 +0000
+++ b/bzrlib/tests/test_btree_index.py 2009-10-19 15:45:10 +0000
@@ -124,6 +124,12 @@
class TestBTreeBuilder(BTreeTestCase):
+ def test_clear_cache(self):
+ builder = btree_index.BTreeBuilder(reference_lists=0, key_elements=1)
+ # This is a no-op, but we need the api to be consistent with other
+ # BTreeGraphIndex apis.
+ builder.clear_cache()
+
def test_empty_1_0(self):
builder = btree_index.BTreeBuilder(key_elements=1, reference_lists=0)
# NamedTemporaryFile dies on builder.finish().read(). weird.
=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py 2009-10-19 15:39:25 +0000
+++ b/bzrlib/tests/test_index.py 2009-10-19 15:45:10 +0000
@@ -173,6 +173,11 @@
"key\x00\x00\t\x00data\n"
"\n", contents)
+ def test_clear_cache(self):
+ builder = GraphIndexBuilder(reference_lists=2)
+ # This is a no-op, but the api should exist
+ builder.clear_cache()
+
def test_node_references_are_byte_offsets(self):
builder = GraphIndexBuilder(reference_lists=1)
builder.add_node(('reference', ), 'data', ([], ))
More information about the bazaar-commits
mailing list