b.chk_map : module documentation

Part of bzrlib

Persistent maps from tuple_of_strings->string using CHK stores.

Overview and current status:

The CHKMap class implements a dict from tuple_of_strings->string by using a trie with internal nodes of 8-bit fan out; The key tuples are mapped to strings by joining them by , and padding shorter keys out to the length of the longest key. Leaf nodes are packed as densely as possible, and internal nodes are all an additional 8-bits wide leading to a sparse upper tree.

Updates to a CHKMap are done preferentially via the apply_delta method, to allow optimisation of the update operation; but individual map/unmap calls are possible and supported. Individual changes via map/unmap are buffered in memory until the _save method is called to force serialisation of the tree. apply_delta records its changes immediately by performing an implicit _save.

TODO:

Densely packed upper nodes.

Function clear_cache Undocumented
Class CHKMap A persistent map from string to string backed by a CHK store.
Class Node Base class defining the protocol for CHK Map nodes.
Class LeafNode A node containing actual key:value pairs.
Class InternalNode A node that contains references to other nodes.
Class CHKMapDifference Iterate the stored pages and key,value pairs for (new - old).
Function iter_interesting_nodes Given root keys, find interesting nodes.
Function _get_cache Get the per-thread page cache.
Function _search_key_plain Map the key tuple into a search string that just uses the key bytes.
Function _deserialise Helper for repositorydetails - convert bytes to a node.
Function _check_key Helper function to assert that a key is properly formatted.
def _get_cache():
Get the per-thread page cache.

We need a function to do this because in a new thread the _thread_caches threading.local object does not have the cache initialized yet.

def clear_cache():
Undocumented
def _search_key_plain(key):
Map the key tuple into a search string that just uses the key bytes.
def _deserialise(bytes, key, search_key_func):
Helper for repositorydetails - convert bytes to a node.
def iter_interesting_nodes(store, interesting_root_keys, uninteresting_root_keys, pb=None):
Given root keys, find interesting nodes.

Evaluate nodes referenced by interesting_root_keys. Ones that are also referenced from uninteresting_root_keys are not considered interesting.

Parametersinteresting_root_keyskeys which should be part of the "interesting" nodes (which will be yielded)
uninteresting_root_keyskeys which should be filtered out of the result set.
ReturnsYield (interesting record, {interesting key:values})
def _check_key(key):
Helper function to assert that a key is properly formatted.

This generally shouldn't be used in production code, but it can be helpful to debug problems.

API Documentation for Bazaar, generated by pydoctor at 2014-04-23 00:01:24.