Rev 13: Return the keys themselves along with the node we care about. in http://bzr.arbash-meinel.com/plugins/index2
John Arbash Meinel
john at arbash-meinel.com
Wed Jul 2 00:19:29 BST 2008
At http://bzr.arbash-meinel.com/plugins/index2
------------------------------------------------------------
revno: 13
revision-id: john at arbash-meinel.com-20080701231851-rvuj7146p23sr25v
parent: john at arbash-meinel.com-20080701231134-73vr4qkr6dogf3h0
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: index2
timestamp: Tue 2008-07-01 18:18:51 -0500
message:
Return the keys themselves along with the node we care about.
-------------- next part --------------
=== modified file 'btree_index.py'
--- a/btree_index.py 2008-07-01 23:11:34 +0000
+++ b/btree_index.py 2008-07-01 23:18:51 +0000
@@ -378,12 +378,16 @@
class FixedDone(Exception): pass
output = []
+ cur_out = []
try:
while True:
if cur_in_key < cur_fixed_key:
- output.append(cur_fixed_offset)
+ cur_keys = []
+ cur_out = (cur_fixed_offset, cur_keys)
+ output.append(cur_out)
while cur_in_key < cur_fixed_key:
+ cur_keys.append(cur_in_key)
try:
cur_in_key = in_keys_iter.next()
except StopIteration:
@@ -402,7 +406,10 @@
except FixedDone:
# There was some input left, but we consumed all of fixed, so we
# have to add one more for the tail
- output.append(len(fixed_keys))
+ cur_keys = [cur_in_key]
+ cur_keys.extend(in_keys_iter)
+ cur_out = (len(fixed_keys), cur_keys)
+ output.append(cur_out)
return output
def iter_entries(self, keys):
=== modified file 'tests/test_btree_index.py'
--- a/tests/test_btree_index.py 2008-07-01 23:11:34 +0000
+++ b/tests/test_btree_index.py 2008-07-01 23:18:51 +0000
@@ -1126,23 +1126,28 @@
search_keys, fixed_keys))
def test_after(self):
- self.assertPositionsForKeys([1], ['b'], ['a'])
- self.assertPositionsForKeys([3], ['e', 'f', 'g'], ['a', 'b', 'c'])
+ self.assertPositionsForKeys([(1, ['b'])], ['b'], ['a'])
+ self.assertPositionsForKeys([(3, ['e', 'f', 'g'])],
+ ['e', 'f', 'g'], ['a', 'b', 'c'])
def test_before(self):
- self.assertPositionsForKeys([0], ['a'], ['b'])
- self.assertPositionsForKeys([0], ['a', 'b', 'c', 'd'], ['e', 'f', 'g'])
+ self.assertPositionsForKeys([(0, ['a'])], ['a'], ['b'])
+ self.assertPositionsForKeys([(0, ['a', 'b', 'c', 'd'])],
+ ['a', 'b', 'c', 'd'], ['e', 'f', 'g'])
def test_exact(self):
- self.assertPositionsForKeys([1], ['a'], ['a'])
- self.assertPositionsForKeys([1, 2], ['a', 'b'], ['a', 'b'])
- self.assertPositionsForKeys([1, 3], ['a', 'c'], ['a', 'b', 'c'])
+ self.assertPositionsForKeys([(1, ['a'])], ['a'], ['a'])
+ self.assertPositionsForKeys([(1, ['a']), (2, ['b'])], ['a', 'b'], ['a', 'b'])
+ self.assertPositionsForKeys([(1, ['a']), (3, ['c'])],
+ ['a', 'c'], ['a', 'b', 'c'])
def test_inbetween(self):
- self.assertPositionsForKeys([1], ['b'], ['a', 'c'])
- self.assertPositionsForKeys([1, 2], ['b', 'c', 'd', 'f', 'g'],
- ['a', 'e', 'h'])
+ self.assertPositionsForKeys([(1, ['b'])], ['b'], ['a', 'c'])
+ self.assertPositionsForKeys([(1, ['b', 'c', 'd']), (2, ['f', 'g'])],
+ ['b', 'c', 'd', 'f', 'g'], ['a', 'e', 'h'])
def test_mixed(self):
- self.assertPositionsForKeys([0, 2, 4], ['a', 'b', 'd', 'e', 'g', 'h'],
+ self.assertPositionsForKeys([(0, ['a', 'b']), (2, ['d', 'e']),
+ (4, ['g', 'h'])],
+ ['a', 'b', 'd', 'e', 'g', 'h'],
['c', 'd', 'f', 'g'])
More information about the bazaar-commits
mailing list