b.c.CHKMap(object) : class documentation

Part of bzrlib.chk_map View In Hierarchy

A persistent map from string to string backed by a CHK store.
Method __init__ Create a CHKMap object.
Method apply_delta Apply a delta to the map.
Class Method from_dict Create a CHKMap in store with initial_value as the content.
Method iter_changes Iterate over the changes between basis and self.
Method iteritems Iterate over the entire CHKMap's contents.
Method key Return the key for this map.
Method __len__ Undocumented
Method map Map a key tuple to value.
Method unmap remove key from the map.
Method _ensure_root Ensure that the root node is an object not a key.
Method _get_node Get a node.
Method _read_bytes Undocumented
Method _dump_tree Return the tree in a string representation.
Method _dump_tree_node For this node and all children, generate a string representation.
Class Method _create_via_map Undocumented
Class Method _create_directly Undocumented
Method _node_key Get the key for a node whether it's a tuple or node.
Method _check_remap Check if nodes can be collapsed.
Method _save Save the map completely.
def __init__(self, store, root_key, search_key_func=None):
Create a CHKMap object.
ParametersstoreThe store the CHKMap is stored in.
root_keyThe root key of the map. None to create an empty CHKMap.
search_key_funcA function mapping a key => bytes. These bytes are then used by the internal nodes to split up leaf nodes into multiple pages.
def apply_delta(self, delta):
Apply a delta to the map.
ParametersdeltaAn iterable of old_key, new_key, new_value tuples. If new_key is not None, then new_key->new_value is inserted into the map; if old_key is not None, then the old mapping of old_key is removed.
def _ensure_root(self):
Ensure that the root node is an object not a key.
def _get_node(self, node):
Get a node.

Note that this does not update the _items dict in objects containing a reference to this node. As such it does not prevent subsequent IO being performed.

ParametersnodeA tuple key or node object.
ReturnsA node object.
def _read_bytes(self, key):
Undocumented
def _dump_tree(self, include_keys=False):
Return the tree in a string representation.
def _dump_tree_node(self, node, prefix, indent, include_keys=True):
For this node and all children, generate a string representation.
@classmethod
def from_dict(klass, store, initial_value, maximum_size=0, key_width=1, search_key_func=None):
Create a CHKMap in store with initial_value as the content.
ParametersstoreThe store to record initial_value in, a VersionedFiles object with 1-tuple keys supporting CHK key generation.
initial_valueA dict to store in store. Its keys and values must be bytestrings.
maximum_sizeThe maximum_size rule to apply to nodes. This determines the size at which no new data is added to a single node.
key_widthThe number of elements in each key_tuple being stored in this map.
search_key_funcA function mapping a key => bytes. These bytes are then used by the internal nodes to split up leaf nodes into multiple pages.
ReturnsThe root chk of the resulting CHKMap.
@classmethod
def _create_via_map(klass, store, initial_value, maximum_size=0, key_width=1, search_key_func=None):
Undocumented
@classmethod
def _create_directly(klass, store, initial_value, maximum_size=0, key_width=1, search_key_func=None):
Undocumented
def iter_changes(self, basis):
Iterate over the changes between basis and self.
ReturnsAn iterator of tuples: (key, old_value, new_value). Old_value is None for keys only in self; new_value is None for keys only in basis.
def iteritems(self, key_filter=None):
Iterate over the entire CHKMap's contents.
def key(self):
Return the key for this map.
def __len__(self):
Undocumented
def map(self, key, value):
Map a key tuple to value.
ParameterskeyA key to map.
valueThe value to assign to key.
def _node_key(self, node):
Get the key for a node whether it's a tuple or node.
def unmap(self, key, check_remap=True):
remove key from the map.
def _check_remap(self):
Check if nodes can be collapsed.
def _save(self):
Save the map completely.
ReturnsThe key of the root node.
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.