/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__btree_serializer.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-04 16:08:12 UTC
  • mto: This revision was merged to the branch mainline in revision 5390.
  • Revision ID: john@arbash-meinel.com-20100804160812-zvqj8pn99i3d6ks3
Trim the class a little bit.

All we need is the common_shift, common_bits and common_mask aren't used.
This puts as at about 42.? bytes/record.
We have 40 actual, and then <3 bytes/record of other overhead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
219
219
        for idx, key in enumerate(all_keys):
220
220
            self.assertEqual(str(idx), leaf[key][0].split()[0])
221
221
 
222
 
    def test_common_mask(self):
 
222
    def test_common_shift(self):
223
223
        # The keys were deliberately chosen so that the first 5 bits all
224
224
        # overlapped, it also happens that a later bit overlaps
225
225
        # Note that by 'overlap' we mean that given bit is either on in all
226
226
        # keys, or off in all keys
227
227
        leaf = self.module._parse_into_chk(_multi_key_content, 1, 0)
228
 
        self.assertEqual(hex(0xF8000000), hex(leaf.common_mask))
229
228
        self.assertEqual(19, leaf.common_shift)
230
 
        self.assertEqual(0xc8000000, leaf.common_bits)
231
229
        # The interesting byte for each key is
232
230
        # (defined as the 8-bits that come after the common prefix)
233
231
        lst = [1, 13, 28, 180, 190, 193, 210, 239]
242
240
    def test_multi_key_same_offset(self):
243
241
        # there is no common prefix, though there are some common bits
244
242
        leaf = self.module._parse_into_chk(_multi_key_same_offset, 1, 0)
245
 
        self.assertEqual(0x00000000, leaf.common_mask)
246
243
        self.assertEqual(24, leaf.common_shift)
247
 
        self.assertEqual(0x00000000, leaf.common_bits)
248
244
        offsets = leaf._test_offsets
249
245
        # The interesting byte is just the first 8-bits of the key
250
246
        lst = [8, 200, 205, 205, 205, 205, 206, 206]
259
255
        # The first 32 bits of all hashes are the same. This is going to be
260
256
        # pretty much impossible, but I don't want to fail because of this
261
257
        leaf = self.module._parse_into_chk(_common_32_bits, 1, 0)
262
 
        self.assertEqual(0xFFFFFF00, leaf.common_mask)
263
258
        self.assertEqual(0, leaf.common_shift)
264
 
        self.assertEqual(0x12345600, leaf.common_bits)
265
259
        lst = [0x78] * 8
266
260
        offsets = leaf._test_offsets
267
261
        self.assertEqual([bisect.bisect_left(lst, x) for x in range(0, 257)],
282
276
            lines.append('%s\0\0%d %d %d %d\n' % (key_str, i, i, i, i))
283
277
        bytes = ''.join(lines)
284
278
        leaf = self.module._parse_into_chk(bytes, 1, 0)
285
 
        self.assertEqual(0xFE000000, leaf.common_mask)
286
279
        self.assertEqual(24-7, leaf.common_shift)
287
 
        self.assertEqual(0x00000000, leaf.common_bits)
288
280
        offsets = leaf._test_offsets
289
281
        # This is the interesting bits for each entry
290
282
        lst = [x // 2 for x in range(500)]