Rev 3828: The previous patches did not actually give a net benefit, so remove them for simplicity. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/hack

John Arbash Meinel john at arbash-meinel.com
Wed Dec 24 20:23:32 GMT 2008


At http://bzr.arbash-meinel.com/branches/bzr/brisbane/hack

------------------------------------------------------------
revno: 3828
revision-id: john at arbash-meinel.com-20081224202312-dwabieqsxc212lt1
parent: john at arbash-meinel.com-20081224192805-lpi28zkruumu4o3y
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: hack
timestamp: Wed 2008-12-24 14:23:12 -0600
message:
  The previous patches did not actually give a net benefit, so remove them for simplicity.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2008-12-24 19:28:05 +0000
+++ b/bzrlib/chk_map.py	2008-12-24 20:23:12 +0000
@@ -511,15 +511,10 @@
             prefix_len = len(self._common_serialised_prefix)
             # prefix_len = 0
             bytes_for_items = (self._raw_size - (prefix_len * self._len))
-        if self._lookup_prefix is None:
-            lookup_len = 0
-        else:
-            lookup_len = len(self._lookup_prefix)
         return (9 # 'chkleaf:\n'
             + len(str(self._maximum_size)) + 1
             + len(str(self._key_width)) + 1
             + len(str(self._len)) + 1
-            + lookup_len + 1
             + prefix_len + 1
             + bytes_for_items)
 
@@ -539,13 +534,10 @@
         maximum_size = int(lines[1])
         width = int(lines[2])
         length = int(lines[3])
-        lookup_prefix = lines[4]
-        assert lookup_prefix[-1] == '\n'
-        lookup_prefix = lookup_prefix[:-1] # Remove the trailing newline
-        prefix = lines[5]
+        pos = 5
+        prefix = lines[4]
         assert prefix[-1] == '\n'
         prefix = prefix[:-1] # Remove the trailing newline
-        pos = 6
         while pos < len(lines):
             elements = (prefix + lines[pos]).split('\x00')
             assert len(elements) == width + 1
@@ -568,18 +560,10 @@
         result._key = key
         result._orig_key = key
         result._key_width = width
-        result._raw_size = (sum(map(len, lines[6:])) # the length of the suffix
+        result._raw_size = (sum(map(len, lines[5:])) # the length of the suffix
             + (length)*(len(prefix))) # prefix
-        if result._len == 0:
-            result._common_serialised_prefix = None
-            result._lookup_prefix = None
-        else:
-            result._common_serialised_prefix = prefix
-            result._lookup_prefix = lookup_prefix
-        # result._compute_lookup_prefix()
-        # assert result._lookup_prefix == lookup_prefix
-        # result._compute_serialised_prefix()
-        # assert result._common_serialised_prefix == prefix
+        result._compute_lookup_prefix()
+        result._compute_serialised_prefix()
         if len(bytes) != result._current_size():
             import pdb; pdb.set_trace()
         assert len(bytes) == result._current_size()
@@ -700,10 +684,6 @@
         lines.append("%d\n" % self._maximum_size)
         lines.append("%d\n" % self._key_width)
         lines.append("%d\n" % self._len)
-        if self._lookup_prefix is None:
-            lines.append('\n')
-        else:
-            lines.append('%s\n' % (self._lookup_prefix,))
         if self._common_serialised_prefix is None:
             lines.append('\n')
         else:
@@ -711,7 +691,6 @@
             # prefix_len = 0
             lines.append('%s\n' % (self._common_serialised_prefix,))
             prefix_len = len(self._common_serialised_prefix)
-
         for key, value in sorted(self._items.items()):
             value_lines = osutils.chunks_to_lines([value + '\n'])
             serialized = "%s\x00%s\n" % (self._serialise_key(key),
@@ -885,7 +864,6 @@
         result._raw_size = None # len(bytes)
         result._node_width = len(prefix)
         result._compute_lookup_prefix()
-        assert result._lookup_prefix == common_prefix
         return result
 
     def iteritems(self, store, key_filter=None):
@@ -1188,26 +1166,6 @@
         #       and cause size changes greater than the length of one key.
         #       So for now, we just add everything to a new Leaf until it
         #       splits, as we know that will give the right answer
-        # Do one quick pass to see if it is even remotely possible for things
-        # to collapse
-        # This is a very wide band. We assume that if we have enough leaf nodes
-        # that their total length > 3 times, then we won't be able to fit that
-        # onto a single leaf node, even with prefix compression.
-        threshold_size = self._maximum_size * 2
-        total_size = 0
-        for prefix, node in self._items.iteritems():
-            if type(node) == tuple:
-                continue
-            elif isinstance(node, InternalNode):
-                # Without looking at any leaf nodes, we are sure
-                def child_is_internal_node(): pass
-                child_is_internal_node()
-                return self
-            total_size += node._current_size()
-            if total_size > threshold_size:
-                def total_size_greater_than_threshold(): pass
-                total_size_greater_than_threshold()
-                return self
         new_leaf = LeafNode()
         new_leaf.set_maximum_size(self._maximum_size)
         new_leaf._key_width = self._key_width
@@ -1218,6 +1176,11 @@
             if type(node) == tuple:
                 keys[node] = prefix
             else:
+                if isinstance(node, InternalNode):
+                    # Without looking at any leaf nodes, we are sure
+                    def child_is_internal_node(): pass
+                    child_is_internal_node()
+                    return self
                 for key, value in node._items.iteritems():
                     if new_leaf._map_no_split(key, value):
                         # Adding this key would cause a split, so we know we



More information about the bazaar-commits mailing list