~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/index.py

MergeĀ upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Indexing facilities."""
18
18
 
99
99
        self._nodes_by_key = None
100
100
        self._key_length = key_elements
101
101
        self._optimize_for_size = False
 
102
        self._combine_backing_indices = True
102
103
 
103
104
    def _check_key(self, key):
104
105
        """Raise BadIndexKey if key is not a valid key for this index."""
315
316
                (len(result.getvalue()), expected_bytes))
316
317
        return result
317
318
 
318
 
    def set_optimize(self, for_size=True):
 
319
    def set_optimize(self, for_size=None, combine_backing_indices=None):
319
320
        """Change how the builder tries to optimize the result.
320
321
 
321
322
        :param for_size: Tell the builder to try and make the index as small as
322
323
            possible.
 
324
        :param combine_backing_indices: If the builder spills to disk to save
 
325
            memory, should the on-disk indices be combined. Set to True if you
 
326
            are going to be probing the index, but to False if you are not. (If
 
327
            you are not querying, then the time spent combining is wasted.)
323
328
        :return: None
324
329
        """
325
330
        # GraphIndexBuilder itself doesn't pay attention to the flag yet, but
326
331
        # other builders do.
327
 
        self._optimize_for_size = for_size
 
332
        if for_size is not None:
 
333
            self._optimize_for_size = for_size
 
334
        if combine_backing_indices is not None:
 
335
            self._combine_backing_indices = combine_backing_indices
328
336
 
329
337
 
330
338
class GraphIndex(object):
1183
1191
                self.__class__.__name__,
1184
1192
                ', '.join(map(repr, self._indices)))
1185
1193
 
1186
 
    @symbol_versioning.deprecated_method(symbol_versioning.one_one)
1187
 
    def get_parents(self, revision_ids):
1188
 
        """See graph._StackedParentsProvider.get_parents.
1189
 
 
1190
 
        This implementation thunks the graph.Graph.get_parents api across to
1191
 
        GraphIndex.
1192
 
 
1193
 
        :param revision_ids: An iterable of graph keys for this graph.
1194
 
        :return: A list of parent details for each key in revision_ids.
1195
 
            Each parent details will be one of:
1196
 
             * None when the key was missing
1197
 
             * (NULL_REVISION,) when the key has no parents.
1198
 
             * (parent_key, parent_key...) otherwise.
1199
 
        """
1200
 
        parent_map = self.get_parent_map(revision_ids)
1201
 
        return [parent_map.get(r, None) for r in revision_ids]
1202
 
 
1203
1194
    def get_parent_map(self, keys):
1204
1195
        """See graph._StackedParentsProvider.get_parent_map"""
1205
1196
        search_keys = set(keys)