system.indexes.christmas_tree module¶
Christmas tree index: a radix trie augmented with buffer-tree-style node buffers.
- class system.indexes.christmas_tree.ChristmasTree(children_per_inner_node: int, descriptor: Descriptor, key_mapping: KeyMapping[Key, Value] = None, number_of_inner_node_levels: int = 0, inner_node_factory=<system.indexes.christmas_tree.ChristmasTree.InnerNodeFactory object>, leaf_factory=<system.indexes.christmas_tree.ChristmasTree.LeafFactory object>)[source]¶
Bases:
RadixTrie,GenericA simple implementation of a Christmas tree data structure.
- class BufferedInnerNode(key_mapping: KeyMapping[Key, Value] = None, parent_descriptor: Descriptor = None, max_buffer_size: int = 30)[source]¶
Bases:
InnerNode,GenericA simple implementation of an inner node in a Christmas tree adding buffer tree-style buffers.
- put(key: Key, value: Value, level: int = 0) None | PutInfo[source]¶
See
Index.put().Buffer-tree variant: appends the pair to this node’s in-memory buffer instead of pushing it down immediately; when the buffer is full it is first flushed to the children. The extra
levelparameter is the current depth of this node in the trie.
- get(key: Key, level: int = 0) Iterator[Value][source]¶
See
PointQueryMixIn.get().Buffer-tree variant: yields matching values from this node’s buffer first and then chains in the values returned by the children, so pairs still sitting in the buffer are not missed. The extra
levelparameter is the current depth of this node in the trie.
- class CrystalBallBufferedInnerNode(key_mapping: KeyMapping[Key, Value] = None, parent_descriptor: Descriptor = None, max_buffer_size: int = 30)[source]¶
Bases:
BufferedInnerNodeAdd a crystal ball to the buffered inner node.
- get(key: Key, level: int = 0) Iterator[Value][source]¶
See
ChristmasTree.BufferedInnerNode.get().Consults the bloom filter first: if the key’s bit is not set the key cannot be present, so an empty iterator is returned without descending; otherwise the buffered-node lookup is delegated to.
- put(key: Key, value: Value, level: int = 0) None | PutInfo[source]¶
See
ChristmasTree.BufferedInnerNode.put().Additionally records the key in the bloom filter before delegating the insertion to the buffered node.
- show(indent: str = '') None[source]¶
See
ChristmasTree.BufferedInnerNode.show().Additionally prints the contents of this node’s bloom filter.
- draw(canvas: Canvas, canvas_height: int = 0, x_offset: int = 0, y_offset: int = 0)[source]¶
See
ChristmasTree.BufferedInnerNode.draw().In addition to the buffered node drawn by the superclass, draws a “crystal ball” (a gradient-filled circle) whose opacity reflects how empty the bloom filter still is: the fuller the filter, the less useful it is and the fainter the ball.
- class InnerNodeFactory(config: str = 'inner')[source]¶
Bases:
InnerNodeFactory,GenericA factory for creating nodes in a Christmas tree.
- new_instance(key_mapping=None, new_descriptor: Descriptor = None) RadixTrie.AbstractNode[Key, Value][source]¶
Create a new instance of the node.
- class LeafFactory[source]¶
Bases:
LeafFactory,GenericA factory for creating leaf nodes in a Christmas tree.
- new_instance(parent_descriptor, left_sibling=None) RadixTrie.LeafNode[Key, Value][source]¶
Create a new instance of the leaf node.