b.c.LeafNode(Node) : class documentation

Part of bzrlib.chk_map View In Hierarchy

A node containing actual key:value pairs.
Instance Variables_itemsA dict of key->value items. The key is in tuple form.
_sizeThe number of bytes that would be used by serializing all of the key/value pairs.
Method __init__ Create a node.
Method __repr__ Undocumented
Class Method deserialise Deserialise bytes, with key key, into a LeafNode.
Method iteritems Iterate over items in the node.
Method map Map key to value.
Method serialise Serialise the LeafNode to store.
Method refs Return the references to other CHK's held by this node.
Method unmap Unmap key from the node.
Method _current_size Answer the current serialised size of this node.
Method _key_value_len Undocumented
Method _search_key Undocumented
Method _map_no_split Map a key to a value.
Method _split We have overflowed.
Method _compute_search_prefix Determine the common search prefix for all keys in this node.
Method _are_search_keys_identical Check to see if the search keys for all entries are the same.
Method _compute_serialised_prefix Determine the common prefix for serialised keys in this node.

Inherited from Node:

Method key Undocumented
Method __len__ Undocumented
Method maximum_size What is the upper limit for adding references to a node.
Method set_maximum_size Set the size threshold for nodes.
Class Method common_prefix Given 2 strings, return the longest prefix common to both.
Class Method common_prefix_for_keys Given a list of keys, find their common prefix.
def __init__(self, search_key_func=None):
Create a node.
Parameterskey_widthThe width of keys for this node.
def __repr__(self):
Undocumented
def _current_size(self):
Answer the current serialised size of this node.

This differs from self._raw_size in that it includes the bytes used for the header.

@classmethod
def deserialise(klass, bytes, key, search_key_func=None):
Deserialise bytes, with key key, into a LeafNode.
ParametersbytesThe bytes of the node.
keyThe key that the serialised node has.
def iteritems(self, store, key_filter=None):
Iterate over items in the node.
Parameterskey_filterA filter to apply to the node. It should be a list/set/dict or similar repeatedly iterable container.
def _key_value_len(self, key, value):
Undocumented
def _search_key(self, key):
Undocumented
def _map_no_split(self, key, value):
Map a key to a value.

This assumes either the key does not already exist, or you have already removed its size and length from self.

ReturnsTrue if adding this node should cause us to split.
def _split(self, store):
We have overflowed.

Split this node into multiple LeafNodes, return it up the stack so that the next layer creates a new InternalNode and references the new nodes.

Returns(common_serialised_prefix, [(node_serialised_prefix, node)])
def map(self, store, key, value):
Map key to value.
def serialise(self, store):
Serialise the LeafNode to store.
ParametersstoreA VersionedFiles honouring the CHK extensions.
ReturnsAn iterable of the keys inserted by this operation.
def refs(self):
Return the references to other CHK's held by this node.
def _compute_search_prefix(self):
Determine the common search prefix for all keys in this node.
ReturnsA bytestring of the longest search key prefix that is unique within this node.
def _are_search_keys_identical(self):
Check to see if the search keys for all entries are the same.

When using a hash as the search_key it is possible for non-identical keys to collide. If that happens enough, we may try overflow a LeafNode, but as all are collisions, we must not split.

def _compute_serialised_prefix(self):
Determine the common prefix for serialised keys in this node.
ReturnsA bytestring of the longest serialised key prefix that is unique within this node.
def unmap(self, store, key):
Unmap key from the node.
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.