Rev 3823: Change the chk_map.[Leaf|Internal]Node.serialize to check before insertion. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/look_before_you_leap
John Arbash Meinel
john at arbash-meinel.com
Wed Feb 18 17:50:27 GMT 2009
At http://bzr.arbash-meinel.com/branches/bzr/brisbane/look_before_you_leap
------------------------------------------------------------
revno: 3823
revision-id: john at arbash-meinel.com-20090218175014-4meosz28tb6ws5qf
parent: john at arbash-meinel.com-20090218163618-isb3yg01ygdx3m2n
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: look_before_you_leap
timestamp: Wed 2009-02-18 11:50:14 -0600
message:
Change the chk_map.[Leaf|Internal]Node.serialize to check before insertion.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py 2009-02-18 16:36:18 +0000
+++ b/bzrlib/chk_map.py 2009-02-18 17:50:14 +0000
@@ -57,6 +57,7 @@
# out, it takes 3.1MB to cache the layer.
_PAGE_CACHE_SIZE = 4*1024*1024
# We are caching bytes so len(value) is perfectly accurate
+# TODO: Consider making this a cache of chunks, rather than bytes
_page_cache = lru_cache.LRUSizeCache(_PAGE_CACHE_SIZE)
@@ -762,8 +763,11 @@
assert serialized.startswith(self._common_serialised_prefix)
lines.append(serialized[prefix_len:])
lines.extend(value_lines)
- sha1, _, _ = store.add_lines((None,), (), lines)
- self._key = ("sha1:" + sha1,)
+ sha1 = osutils.sha_strings(lines)
+ key = ('sha1:' + sha1,)
+ if not store.has_key(key):
+ store.add_lines(key, (), lines, random_id=True)
+ self._key = key
bytes = ''.join(lines)
if len(bytes) != self._current_size():
import pdb; pdb.set_trace()
@@ -1088,8 +1092,11 @@
serialised = "%s\x00%s\n" % (prefix, key)
assert serialised.startswith(self._search_prefix)
lines.append(serialised[prefix_len:])
- sha1, _, _ = store.add_lines((None,), (), lines)
- self._key = ("sha1:" + sha1,)
+ sha1 = osutils.sha_strings(lines)
+ key = ('sha1:' + sha1,)
+ if not store.has_key(key):
+ store.add_lines(key, (), lines, random_id=True)
+ self._key = key
_page_cache.add(self._key, ''.join(lines))
yield self._key
More information about the bazaar-commits
mailing list