~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/btree_index.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

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
162
164
        :param references: An iterable of iterables of keys. Each is a
163
165
            reference to another key.
164
166
        :param value: The value to associate with the key. It may be any
165
 
            bytes as long as it does not contain \0 or \n.
 
167
            bytes as long as it does not contain \\0 or \\n.
166
168
        """
167
169
        # Ensure that 'key' is a StaticTuple
168
170
        key = static_tuple.StaticTuple.from_sequence(key).intern()
197
199
            new_backing_file, size = self._spill_mem_keys_without_combining()
198
200
        # Note: The transport here isn't strictly needed, because we will use
199
201
        #       direct access to the new_backing._file object
200
 
        new_backing = BTreeGraphIndex(transport.get_transport('.'),
 
202
        new_backing = BTreeGraphIndex(transport.get_transport_from_path('.'),
201
203
                                      '<temp>', size)
202
204
        # GC will clean up the file
203
205
        new_backing._file = new_backing_file
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"