souffle
2.0.2-371-g6315b36
|
The actual, generic node implementation covering the operations for both, inner and leaf nodes. More...
#include <BTree.h>
Public Member Functions | |
inner_node & | asInnerNode () |
A utility function providing a reference to this node as an inner node. More... | |
const inner_node & | asInnerNode () const |
A utility function providing a reference to this node as a const inner node. More... | |
template<typename Comp > | |
bool | check (Comp &comp, const node *root) const |
A function to verify the consistency of this node. More... | |
node * | clone () const |
A deep-copy operation creating a clone of this node. More... | |
std::vector< chunk > & | collectChunks (std::vector< chunk > &res, size_type num, const iterator &begin, const iterator &end) const |
A function decomposing the sub-tree rooted by this node into approximately equally sized chunks. More... | |
size_type | countEntries () const |
Counts the number of entries contained in the sub-tree rooted by this node. More... | |
size_type | countNodes () const |
Counts the number of nodes contained in the sub-tree rooted by this node. More... | |
node * | getChild (size_type s) const |
Obtains a reference to the child of the given index. More... | |
node ** | getChildren () |
Obtains a pointer to the array of child-pointers of this node – if it is an inner node. More... | |
node *const * | getChildren () const |
Obtains a pointer to the array of const child-pointers of this node – if it is an inner node. More... | |
size_type | getDepth () const |
Computes the number of nested levels of the tree rooted by this node. More... | |
size_type | getMemoryUsage () const |
Determines the amount of memory used by the sub-tree rooted by this node. More... | |
int | getSplitPoint (int) |
Obtains the point at which full nodes should be split. More... | |
bool | isEmpty () const |
Checks whether this node is empty – can happen due to biased insertion. More... | |
bool | isFull () const |
Checks whether this node is full. More... | |
node (bool inner) | |
void | printTree (std::ostream &out, const std::string &prefix) const |
Prints a textual representation of this tree to the given output stream. More... | |
int | rebalance_or_split (node **root, lock_type &root_lock, int idx) |
Moves keys from this node to one of its siblings or splits this node to make some space for the insertion of an element at position idx. More... | |
void | split (node **root, lock_type &root_lock, int idx) |
Splits this node. More... | |
Public Member Functions inherited from souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::base | |
base (bool inner) | |
A simple constructor for nodes. More... | |
size_type | getNumElements () const |
node * | getParent () const |
field_index_type | getPositionInParent () const |
bool | isInner () const |
bool | isLeaf () const |
Data Fields | |
Key | keys [maxKeys] |
Data Fields inherited from souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::base | |
const bool | inner |
size_type | numElements |
node * | parent |
field_index_type | position |
Static Public Attributes | |
static constexpr size_t | desiredNumKeys |
The number of keys/node desired by the user. More... | |
static constexpr size_t | maxKeys = (desiredNumKeys > 3) ? desiredNumKeys : 3 |
The actual number of keys/node corrected by functional requirements. More... | |
Private Member Functions | |
void | grow_parent (node **root, lock_type &root_lock, node *sibling) |
Inserts a new sibling into the parent of this node utilizing the last key of this node as a separation key. More... | |
void | insert_inner (node **root, lock_type &root_lock, unsigned pos, node *predecessor, const Key &key, node *newNode) |
Inserts a new element into an inner node (for internal use only). More... | |
The actual, generic node implementation covering the operations for both, inner and leaf nodes.
|
inline |
Definition at line 396 of file BTree.h.
References i, and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::keys.
Referenced by souffle::detail::btree< Key, detail::comparator< Key >, std::allocator< Key >, blockSize, typename detail::default_strategy< Key >::type, isSet, detail::comparator< Key >, detail::updater< Key > >::check(), souffle::detail::btree< Key, detail::comparator< Key >, std::allocator< Key >, blockSize, typename detail::default_strategy< Key >::type, isSet, detail::comparator< Key >, detail::updater< Key > >::covers(), souffle::detail::btree< Key, detail::comparator< Key >, std::allocator< Key >, blockSize, typename detail::default_strategy< Key >::type, isSet, detail::comparator< Key >, detail::updater< Key > >::coversUpperBound(), souffle::detail::btree< Key, detail::comparator< Key >, std::allocator< Key >, blockSize, typename detail::default_strategy< Key >::type, isSet, detail::comparator< Key >, detail::updater< Key > >::weak_covers(), and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::inner_node::~inner_node().
|
inline |
A utility function providing a reference to this node as an inner node.
Definition at line 434 of file BTree.h.
References souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::getChild(), souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::getDepth(), and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::base::isLeaf().
Referenced by souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::getChildren(), and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::getMemoryUsage().
|
inline |
|
inline |
|
inline |
|
inline |
A function decomposing the sub-tree rooted by this node into approximately equally sized chunks.
To minimize computational overhead, no strict load balance nor limit on the number of actual chunks is given.
res | .. the list of chunks to be extended |
num | .. the number of chunks to be produced |
begin | .. the iterator to start the first chunk with |
end | .. the iterator to end the last chunk with |
Definition at line 927 of file BTree.h.
|
inline |
Counts the number of entries contained in the sub-tree rooted by this node.
Definition at line 478 of file BTree.h.
References souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::getChild(), souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::getMemoryUsage(), i, souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::base::isLeaf(), and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::base::numElements.
Referenced by souffle::detail::btree< Key, detail::comparator< Key >, std::allocator< Key >, blockSize, typename detail::default_strategy< Key >::type, isSet, detail::comparator< Key >, detail::updater< Key > >::btree(), and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::countNodes().
|
inline |
Counts the number of nodes contained in the sub-tree rooted by this node.
Definition at line 463 of file BTree.h.
References souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::countEntries(), souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::getChild(), i, souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::base::isLeaf(), and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::base::numElements.
|
inline |
Obtains a reference to the child of the given index.
Definition at line 523 of file BTree.h.
Referenced by souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::asInnerNode(), souffle::detail::btree< Key, detail::comparator< Key >, std::allocator< Key >, blockSize, typename detail::default_strategy< Key >::type, isSet, detail::comparator< Key >, detail::updater< Key > >::check(), souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::countEntries(), souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::countNodes(), and souffle::detail::btree< Key, detail::comparator< Key >, std::allocator< Key >, blockSize, typename detail::default_strategy< Key >::type, isSet, detail::comparator< Key >, detail::updater< Key > >::operator=().
|
inline |
Obtains a pointer to the array of child-pointers of this node – if it is an inner node.
Definition at line 508 of file BTree.h.
References souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::asInnerNode(), and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::inner_node::children.
Referenced by souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::iterator::operator*(), and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::printTree().
|
inline |
Obtains a pointer to the array of const child-pointers of this node – if it is an inner node.
|
inline |
Computes the number of nested levels of the tree rooted by this node.
Definition at line 452 of file BTree.h.
Referenced by souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::asInnerNode().
|
inline |
Determines the amount of memory used by the sub-tree rooted by this node.
Definition at line 493 of file BTree.h.
References souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::asInnerNode(), and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::inner_node::children.
Referenced by souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::countEntries().
|
inline |
Obtains the point at which full nodes should be split.
Conventional b-trees always split in half. However, in cases where in-order insertions are frequent, a split assigning larger portions to the right fragment provide higher performance and a better node-filling rate.
|
inlineprivate |
Inserts a new sibling into the parent of this node utilizing the last key of this node as a separation key.
(for internal use only)
root | .. a pointer to the root-pointer of the containing tree |
sibling | .. the new right-sibling to be add to the parent node |
|
inlineprivate |
|
inline |
|
inline |
|
inline |
Prints a textual representation of this tree to the given output stream.
This feature is mainly intended for debugging and tuning purposes.
Definition at line 871 of file BTree.h.
References souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::getChildren(), i, and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::base::numElements.
|
inline |
Moves keys from this node to one of its siblings or splits this node to make some space for the insertion of an element at position idx.
Returns the number of elements moved to the left side, 0 in case of a split. The number of moved elements will be <= the given idx.
root | .. the root node of the b-tree being part of |
idx | .. the position of the insert triggering this operation |
Definition at line 632 of file BTree.h.
References souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::root, souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::root_lock, and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::split().
|
inline |
Splits this node.
root | .. a pointer to the root-pointer of the enclosing b-tree (might have to be updated if the root-node needs to be split) |
idx | .. the position of the insert causing the split |
Definition at line 567 of file BTree.h.
References i, j, and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::keys.
|
staticconstexpr |
Key souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::keys[maxKeys] |
Definition at line 393 of file BTree.h.
Referenced by souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::node(), and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::split().
|
staticconstexpr |
The actual number of keys/node corrected by functional requirements.
Definition at line 390 of file BTree.h.
Referenced by souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::getChild(), and souffle::detail::btree< Key, Comparator, Allocator, blockSize, SearchStrategy, isSet, WeakComparator, Updater >::node::isEmpty().