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.
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. |
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.
Evaluate nodes referenced by interesting_root_keys. Ones that are also referenced from uninteresting_root_keys are not considered interesting.
Parameters | interesting_root_keys | keys which should be part of the "interesting" nodes (which will be yielded) |
uninteresting_root_keys | keys which should be filtered out of the result set. | |
Returns | Yield (interesting record, {interesting key:values}) |