Rev 4780: (jam) Don't pad single-node btree indexes. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Sat Oct 31 04:20:52 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4780 [merge]
revision-id: pqm at pqm.ubuntu.com-20091031042050-avqp46clpe9fabzm
parent: pqm at pqm.ubuntu.com-20091031033513-uxf0qaggw1uaere8
parent: john at arbash-meinel.com-20091029161543-tdqlm2l4e2z5o7le
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2009-10-31 04:20:50 +0000
message:
(jam) Don't pad single-node btree indexes.
modified:
bzrlib/btree_index.py index.py-20080624222253-p0x5f92uyh5hw734-7
bzrlib/tests/test_btree_index.py test_index.py-20080624222253-p0x5f92uyh5hw734-13
=== modified file 'bzrlib/btree_index.py'
--- a/bzrlib/btree_index.py 2009-10-19 15:39:25 +0000
+++ b/bzrlib/btree_index.py 2009-10-29 16:15:43 +0000
@@ -411,7 +411,8 @@
# Special case the first node as it may be prefixed
node = row.spool.read(_PAGE_SIZE)
result.write(node[reserved:])
- result.write("\x00" * (reserved - position))
+ if len(node) == _PAGE_SIZE:
+ result.write("\x00" * (reserved - position))
position = 0 # Only the root row actually has an offset
copied_len = osutils.pumpfile(row.spool, result)
if copied_len != (row.nodes - 1) * _PAGE_SIZE:
=== modified file 'bzrlib/tests/test_btree_index.py'
--- a/bzrlib/tests/test_btree_index.py 2009-10-20 04:25:27 +0000
+++ b/bzrlib/tests/test_btree_index.py 2009-10-29 16:15:43 +0000
@@ -161,7 +161,7 @@
temp_file = builder.finish()
content = temp_file.read()
del temp_file
- self.assertEqual(158, len(content))
+ self.assertEqual(131, len(content))
self.assertEqual(
"B+Tree Graph Index 2\nnode_ref_lists=0\nkey_elements=1\nlen=5\n"
"row_lengths=1\n",
@@ -185,7 +185,7 @@
temp_file = builder.finish()
content = temp_file.read()
del temp_file
- self.assertEqual(264, len(content))
+ self.assertEqual(238, len(content))
self.assertEqual(
"B+Tree Graph Index 2\nnode_ref_lists=2\nkey_elements=2\nlen=10\n"
"row_lengths=1\n",
@@ -251,7 +251,7 @@
temp_file = builder.finish()
content = temp_file.read()
del temp_file
- self.assertEqual(181, len(content))
+ self.assertEqual(155, len(content))
self.assertEqual(
"B+Tree Graph Index 2\nnode_ref_lists=0\nkey_elements=1\nlen=10\n"
"row_lengths=1\n",
@@ -718,7 +718,7 @@
# The entire index should have been read, as it is one page long.
self.assertEqual([('readv', 'index', [(0, size)], False, None)],
transport._activity)
- self.assertEqual(1199, size)
+ self.assertEqual(1173, size)
def test__read_nodes_no_size_one_page_reads_once(self):
self.make_index(nodes=[(('key',), 'value', ())])
@@ -772,7 +772,7 @@
# The entire index should have been read linearly.
self.assertEqual([('readv', 'index', [(0, size)], False, None)],
transport._activity)
- self.assertEqual(1514, size)
+ self.assertEqual(1488, size)
def test_validate_two_pages(self):
builder = btree_index.BTreeBuilder(key_elements=2, reference_lists=2)
More information about the bazaar-commits
mailing list