Rev 4501: Change the api for _LeafNode to use _LeafNode.get rather than directly in http://bazaar.launchpad.net/~jameinel/bzr/1.17-btree-faster

John Arbash Meinel john at arbash-meinel.com
Wed Jul 1 21:43:35 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/1.17-btree-faster

------------------------------------------------------------
revno: 4501
revision-id: john at arbash-meinel.com-20090701204325-gcgu6ovclsgbbfrj
parent: pqm at pqm.ubuntu.com-20090701173004-xmeu77pfroy9iklo
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-btree-faster
timestamp: Wed 2009-07-01 15:43:25 -0500
message:
  Change the api for _LeafNode to use _LeafNode.get rather than directly
  accessing LeafNode.keys.
-------------- next part --------------
=== modified file 'bzrlib/_btree_serializer_py.py'
--- a/bzrlib/_btree_serializer_py.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/_btree_serializer_py.py	2009-07-01 20:43:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008 Canonical Ltd
+# Copyright (C) 2008, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by

=== modified file 'bzrlib/_btree_serializer_pyx.pyx'
--- a/bzrlib/_btree_serializer_pyx.pyx	2009-06-22 12:52:39 +0000
+++ b/bzrlib/_btree_serializer_pyx.pyx	2009-07-01 20:43:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008 Canonical Ltd
+# Copyright (C) 2008, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by

=== modified file 'bzrlib/btree_index.py'
--- a/bzrlib/btree_index.py	2009-06-22 12:52:39 +0000
+++ b/bzrlib/btree_index.py	2009-07-01 20:43:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008 Canonical Ltd
+# Copyright (C) 2008, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 import struct
 import tempfile
 import zlib
+import sys
 
 from bzrlib import (
     chunk_writer,
@@ -598,6 +599,13 @@
         self.keys = dict(_btree_serializer._parse_leaf_lines(bytes,
             key_length, ref_list_length))
 
+    def __len__(self):
+        return len(self.keys)
+
+    def get(self, key):
+        """Get the value, refs or None for a given key."""
+        return self.keys.get(key, None)
+
 
 class _InternalNode(object):
     """An internal node for a serialised B+Tree index."""
@@ -1117,8 +1125,9 @@
                 continue
             node = nodes[node_index]
             for next_sub_key in sub_keys:
-                if next_sub_key in node.keys:
-                    value, refs = node.keys[next_sub_key]
+                val = node.get(next_sub_key)
+                if val is not None:
+                    value, refs = val
                     if self.node_ref_lists:
                         yield (self, next_sub_key, value, refs)
                     else:



More information about the bazaar-commits mailing list