~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/btree_index.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""B+Tree indices"""
19
19
 
 
20
from __future__ import absolute_import
 
21
 
20
22
import cStringIO
21
23
 
22
24
from bzrlib.lazy_import import lazy_import
294
296
            flag when writing out. This is used by the _spill_mem_keys_to_disk
295
297
            functionality.
296
298
        """
 
299
        new_leaf = False
297
300
        if rows[-1].writer is None:
298
301
            # opening a new leaf chunk;
 
302
            new_leaf = True
299
303
            for pos, internal_row in enumerate(rows[:-1]):
300
304
                # flesh out any internal nodes that are needed to
301
305
                # preserve the height of the tree
320
324
                optimize_for_size=self._optimize_for_size)
321
325
            rows[-1].writer.write(_LEAF_FLAG)
322
326
        if rows[-1].writer.write(line):
 
327
            # if we failed to write, despite having an empty page to write to,
 
328
            # then line is too big. raising the error avoids infinite recursion
 
329
            # searching for a suitably large page that will not be found.
 
330
            if new_leaf:
 
331
                raise errors.BadIndexKey(string_key)
323
332
            # this key did not fit in the node:
324
333
            rows[-1].finish_node()
325
334
            key_line = string_key + "\n"