b.i.CombinedGraphIndex(object) : class documentation

Part of bzrlib.index View In Hierarchy

A GraphIndex made up from smaller GraphIndices.

The backing indices must implement GraphIndex, and are presumed to be static data.

Queries against the combined index will be made against the first index, and then the second and so on. The order of indices can thus influence performance significantly. For example, if one index is on local disk and a second on a remote server, the local disk index should be before the other in the index list.

Also, queries tend to need results from the same indices as previous queries. So the indices will be reordered after every query to put the indices that had the result(s) of that query first (while otherwise preserving the relative ordering).

Method __init__ Create a CombinedGraphIndex backed by indices.
Method __repr__ Undocumented
Method clear_cache See GraphIndex.clear_cache()
Method get_parent_map See graph.StackedParentsProvider.get_parent_map
Method insert_index Insert a new index in the list of indices to query.
Method iter_all_entries Iterate over all keys within the index
Method iter_entries Iterate over keys within the index.
Method iter_entries_prefix Iterate over keys within the index using prefix matching.
Method find_ancestry Find the complete ancestry for the given set of keys.
Method key_count Return an estimate of the number of keys in this index.
Method set_sibling_indices Set the CombinedGraphIndex objects to reorder after reordering self.
Method validate Validate that everything in the index can be accessed.
Method _move_to_front Rearrange self._indices so that hit_indices are first.
Method _move_to_front_by_index Core logic for _move_to_front.
Method _move_to_front_by_name Moves indices named by 'hit_names' to front of the search order, as
Method _reload_or_raise We just got a NoSuchFile exception.
def __init__(self, indices, reload_func=None):
Create a CombinedGraphIndex backed by indices.
ParametersindicesAn ordered list of indices to query for data.
reload_funcA function to call if we find we are missing an index. Should have the form reload_func() => True/False to indicate if reloading actually changed anything.
def __repr__(self):
Undocumented
def clear_cache(self):
See GraphIndex.clear_cache()
def get_parent_map(self, keys):
See graph.StackedParentsProvider.get_parent_map
def insert_index(self, pos, index, name=None):
Insert a new index in the list of indices to query.
ParametersposThe position to insert the index.
indexThe index to insert.
namea name for this index, e.g. a pack name. These names can be used to reflect index reorderings to related CombinedGraphIndex instances that use the same names. (see set_sibling_indices)
def iter_all_entries(self):
Iterate over all keys within the index

Duplicate keys across child indices are presumed to have the same value and are only reported once.

ReturnsAn iterable of (index, key, reference_lists, value). There is no defined order for the result iteration - it will be in the most efficient order for the index.
def iter_entries(self, keys):
Iterate over keys within the index.

Duplicate keys across child indices are presumed to have the same value and are only reported once.

ParameterskeysAn iterable providing the keys to be retrieved.
ReturnsAn iterable of (index, key, reference_lists, value). There is no defined order for the result iteration - it will be in the most efficient order for the index.
def iter_entries_prefix(self, keys):
Iterate over keys within the index using prefix matching.

Duplicate keys across child indices are presumed to have the same value and are only reported once.

Prefix matching is applied within the tuple of a key, not to within the bytestring of each key element. e.g. if you have the keys ('foo', 'bar'), ('foobar', 'gam') and do a prefix search for ('foo', None) then only the former key is returned.

ParameterskeysAn iterable providing the key prefixes to be retrieved. Each key prefix takes the form of a tuple the length of a key, but with the last N elements 'None' rather than a regular bytestring. The first element cannot be 'None'.
ReturnsAn iterable as per iter_all_entries, but restricted to the keys with a matching prefix to those supplied. No additional keys will be returned, and every match that is in the index will be returned.
def _move_to_front(self, hit_indices):
Rearrange self._indices so that hit_indices are first.

Order is maintained as much as possible, e.g. the first unhit index will be the first index in _indices after the hit_indices, and the hit_indices will be present in exactly the order they are passed to _move_to_front.

_move_to_front propagates to all objects in self._sibling_indices by calling _move_to_front_by_name.

def _move_to_front_by_index(self, hit_indices):
Core logic for _move_to_front.

Returns a list of names corresponding to the hit_indices param.

def _move_to_front_by_name(self, hit_names):
Moves indices named by 'hit_names' to front of the search order, as described in _move_to_front.
def find_ancestry(self, keys, ref_list_num):
Find the complete ancestry for the given set of keys.

Note that this is a whole-ancestry request, so it should be used sparingly.

ParameterskeysAn iterable of keys to look for
ref_list_numThe reference list which references the parents we care about.
Returns(parent_map, missing_keys)
def key_count(self):
Return an estimate of the number of keys in this index.

For CombinedGraphIndex this is approximated by the sum of the keys of the child indices. As child indices may have duplicate keys this can have a maximum error of the number of child indices * largest number of keys in any index.

def _reload_or_raise(self):
We just got a NoSuchFile exception.

Try to reload the indices, if it fails, just raise the current exception.

def set_sibling_indices(self, sibling_combined_graph_indices):
Set the CombinedGraphIndex objects to reorder after reordering self.
def validate(self):
Validate that everything in the index can be accessed.
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.