579
579
# The entire index should have been requested (as we generally have the
580
580
# size available, and doing many small readvs is inappropriate).
581
581
# We can't tell how much was actually read here, but - check the code.
582
self.assertEqual([('get', 'index'),
583
('readv', 'index', [(0, 72)], False, None)],
582
self.assertEqual([('get', 'index')], transport._activity)
586
584
def test_empty_key_count(self):
587
585
builder = btree_index.BTreeBuilder(key_elements=1, reference_lists=0)
612
610
transport._activity)
613
611
self.assertEqual(1199, size)
613
def test__read_nodes_no_size_one_page_reads_once(self):
614
self.make_index(nodes=[(('key',), 'value', ())])
615
trans = get_transport('trace+' + self.get_url())
616
index = btree_index.BTreeGraphIndex(trans, 'index', None)
617
del trans._activity[:]
618
nodes = dict(index._read_nodes([0]))
619
self.assertEqual([0], nodes.keys())
621
self.assertEqual([('key',)], node.keys.keys())
622
self.assertEqual([('get', 'index')], trans._activity)
624
def test__read_nodes_no_size_multiple_pages(self):
625
index = self.make_index(2, 2, nodes=self.make_nodes(160, 2, 2))
627
num_pages = index._row_offsets[-1]
628
# Reopen with a traced transport and no size
629
trans = get_transport('trace+' + self.get_url())
630
index = btree_index.BTreeGraphIndex(trans, 'index', None)
631
del trans._activity[:]
632
nodes = dict(index._read_nodes([0]))
633
self.assertEqual(range(num_pages), nodes.keys())
615
635
def test_2_levels_key_count_2_2(self):
616
636
builder = btree_index.BTreeBuilder(key_elements=2, reference_lists=2)
617
637
nodes = self.make_nodes(160, 2, 2)
699
719
btree_index.BTreeGraphIndex(transport1, 'index', 10) !=
700
720
btree_index.BTreeGraphIndex(transport1, 'index', 20))
722
def test_iter_all_only_root_no_size(self):
723
self.make_index(nodes=[(('key',), 'value', ())])
724
trans = get_transport('trace+' + self.get_url(''))
725
index = btree_index.BTreeGraphIndex(trans, 'index', None)
726
del trans._activity[:]
727
self.assertEqual([(('key',), 'value')],
728
[x[1:] for x in index.iter_all_entries()])
729
self.assertEqual([('get', 'index')], trans._activity)
702
731
def test_iter_all_entries_reads(self):
703
732
# iterating all entries reads the header, then does a linear