souffle
2.0.2-371-g6315b36
|
A sparse array simulates an array associating to every element of uint32_t an element of a generic type T.
More...
#include <Brie.h>
|
union | Cell |
| The value stored in a single cell of a inner or leaf node. More...
|
|
struct | FirstInfoSnapshot |
| A struct summarizing the state of the first node reference. More...
|
|
struct | Node |
| The node type of the internally maintained tree. More...
|
|
struct | op_context |
| A struct to be utilized as a local, temporal context by client code to speed up the execution of various operations (optional parameter). More...
|
|
struct | RootInfo |
| A struct describing all the information required by the container class to manage the wrapped up tree. More...
|
|
struct | RootInfoSnapshot |
| A struct to cover a snapshot of the root node state. More...
|
|
|
void | addAll (const SparseArray &other) |
| Adds all the values stored in the given array to this array. More...
|
|
iterator | begin () const |
| Obtains an iterator referencing the first non-default element or end in case there are no such elements. More...
|
|
void | clear () |
| Resets the content of this array to default values for each contained element. More...
|
|
void | dump (bool detail=false, std::ostream &out=std::cout) const |
| A debug utility printing the internal structure of this sparse array to the given output stream. More...
|
|
bool | empty () const |
| Tests whether this sparse array is empty, thus it only contains default-values, or not. More...
|
|
iterator | end () const |
| An iterator referencing the position after the last non-default element. More...
|
|
iterator | find (index_type i) const |
| An operation to obtain an iterator referencing an element addressed by the given index. More...
|
|
iterator | find (index_type i, op_context &ctxt) const |
| An operation to obtain an iterator referencing an element addressed by the given index. More...
|
|
value_type & | get (index_type i) |
| Obtains a mutable reference to the value addressed by the given index. More...
|
|
value_type & | get (index_type i, op_context &ctxt) |
| Obtains a mutable reference to the value addressed by the given index. More...
|
|
atomic_value_type & | getAtomic (index_type i) |
| Obtains a mutable reference to the atomic value addressed by the given index. More...
|
|
atomic_value_type & | getAtomic (index_type i, op_context &ctxt) |
| Obtains a mutable reference to the atomic value addressed by the given index. More...
|
|
std::size_t | getMemoryUsage () const |
| Computes the total memory usage of this data structure. More...
|
|
value_type | lookup (index_type i) const |
| Obtains the value associated to index i – which might be the default value of the covered type if the value hasn't been defined previously. More...
|
|
value_type | lookup (index_type i, op_context &ctxt) const |
| Obtains the value associated to index i – which might be the default value of the covered type if the value hasn't been defined previously. More...
|
|
iterator | lowerBound (index_type i) const |
| An operation obtaining the smallest non-default element such that it's index is >= the given index. More...
|
|
iterator | lowerBound (index_type i, op_context &) const |
| An operation obtaining the smallest non-default element such that it's index is >= the given index. More...
|
|
SparseArray & | operator= (const SparseArray &other) |
| An assignment creating a deep copy of the handed in array structure (utilizing the copy functor provided as a template parameter). More...
|
|
SparseArray & | operator= (SparseArray &&other) |
| An assignment operation taking over ownership from a r-value reference to a sparse array. More...
|
|
value_type | operator[] (index_type i) const |
| Obtains the value associated to index i – which might be the default value of the covered type if the value hasn't been defined previously. More...
|
|
std::size_t | size () const |
| Computes the number of non-empty elements within this sparse array. More...
|
|
| SparseArray () |
| A default constructor creating an empty sparse array. More...
|
|
| SparseArray (const SparseArray &other) |
| A copy constructor for sparse arrays. More...
|
|
| SparseArray (SparseArray &&other) |
| A r-value based copy constructor for sparse arrays. More...
|
|
void | update (index_type i, const value_type &val) |
| Updates the value stored in cell i by the given value. More...
|
|
void | update (index_type i, const value_type &val, op_context &ctxt) |
| Updates the value stored in cell i by the given value. More...
|
|
iterator | upperBound (index_type i) const |
| An operation obtaining the smallest non-default element such that it's index is greater the given index. More...
|
|
iterator | upperBound (index_type i, op_context &ctxt) const |
| An operation obtaining the smallest non-default element such that it's index is greater the given index. More...
|
|
| ~SparseArray () |
| A destructor for sparse arrays clearing up the internally maintained data structure. More...
|
|
|
static Node * | clone (const Node *node, int level) |
| Clones the given node and all its sub-nodes. More...
|
|
static Node * | findFirst (Node *node, int level) |
| Obtains the left-most leaf-node of the tree rooted by the given node with the given level. More...
|
|
static void | freeNodes (Node *node, int level) |
| Destroys a node and all its sub-nodes recursively. More...
|
|
static index_type | getIndex (brie_element_type a, unsigned level) |
| Obtains the index within the arrays of cells of a given index on a given level of the internally maintained tree. More...
|
|
static index_type | getLevelMask (unsigned level) |
| Computes the bit-mask to be applicable to obtain the offset of a node on a given tree level. More...
|
|
static std::size_t | getMemoryUsage (const Node *node, int level) |
| Computes the memory usage of the given sub-tree. More...
|
|
static bool | inBoundaries (index_type a, uint32_t levels, index_type offset) |
| Tests whether the given index is within the boundaries defined by the given tree hight and offset. More...
|
|
static void | merge (const Node *parent, Node *&trg, const Node *src, int levels) |
| A static operation utilized internally for merging sub-trees recursively. More...
|
|
static Node * | newNode () |
| Creates new nodes and initializes them with 0. More...
|
|
template<typename T, unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
class souffle::SparseArray< T, BITS, merge_op, copy_op >
A sparse array simulates an array associating to every element of uint32_t an element of a generic type T.
Any non-defined element will be default-initialized utilizing the detail::brie::default_factory functor.
Internally the array is organized as a balanced tree. The leaf level of the tree corresponds to the elements of the represented array. Inner nodes utilize individual bits of the indices to reference sub-trees. For efficiency reasons, only the minimal sub-tree required to cover all non-null / non-default values stored in the array is maintained. Furthermore, several levels of nodes are aggreated in a B-tree like fashion to inprove cache utilization and reduce the number of steps required for lookup and insert operations.
- Template Parameters
-
T | the type of the stored elements |
BITS | the number of bits consumed per node-level e.g. if it is set to 3, the resulting tree will be of a degree of 2^3=8, and thus 8 child-pointers will be stored in each inner node and as many values will be stored in each leaf node. |
merge_op | the functor to be utilized when merging the content of two instances of this type. |
copy_op | a functor to be applied to each stored value when copying an instance of this array. For instance, this is utilized by the trie implementation to create a clone of each sub-tree instead of preserving the original pointer. |
Definition at line 339 of file Brie.h.
◆ atomic_value_type
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ index_type
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ iterator
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ key_type
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ this_t
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ value_type
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ SparseArray() [1/3]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
A default constructor creating an empty sparse array.
Definition at line 419 of file Brie.h.
425 :
unsynced(RootInfo{other.unsynced.root, other.unsynced.levels, other.unsynced.offset,
◆ SparseArray() [2/3]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
A copy constructor for sparse arrays.
It creates a deep copy of the data structure maintained by the handed in array instance.
Definition at line 426 of file Brie.h.
427 other.unsynced.root =
nullptr;
428 other.unsynced.levels = 0;
429 other.unsynced.first =
nullptr;
◆ SparseArray() [3/3]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
A r-value based copy constructor for sparse arrays.
It takes over ownership of the structure maintained by the handed in array.
Definition at line 440 of file Brie.h.
446 if (
this == &other)
return *
this;
◆ ~SparseArray()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
A destructor for sparse arrays clearing up the internally maintained data structure.
Definition at line 452 of file Brie.h.
◆ addAll()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Adds all the values stored in the given array to this array.
Definition at line 1042 of file Brie.h.
1055 Node*& next = (*node)->cell[x].ptr;
1059 next->parent = *node;
1067 merge((*node)->parent, *node, other.unsynced.root, level);
1080 using iterator = SparseArrayIter<this_t>;
Referenced by souffle::SparseBitMap< BITS >::size().
◆ begin()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ clean()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Conducts a cleanup of the internal tree structure.
Definition at line 1352 of file Brie.h.
◆ clear()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Resets the content of this array to default values for each contained element.
Definition at line 572 of file Brie.h.
◆ clone()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Clones the given node and all its sub-nodes.
Definition at line 1361 of file Brie.h.
1365 auto cur =
clone(node->cell[
i].ptr, level - 1);
1366 if (cur !=
nullptr) {
1369 res->cell[
i].ptr = cur;
1380 static Node*
findFirst(Node* node,
int level) {
◆ dump() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
void souffle::SparseArray< T, BITS, merge_op, copy_op >::dump |
( |
bool |
detail = false , |
|
|
std::ostream & |
out = std::cout |
|
) |
| const |
|
inline |
A debug utility printing the internal structure of this sparse array to the given output stream.
Definition at line 1312 of file Brie.h.
◆ dump() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
void souffle::SparseArray< T, BITS, merge_op, copy_op >::dump |
( |
bool |
detailed, |
|
|
std::ostream & |
out, |
|
|
const Node & |
node, |
|
|
int |
level, |
|
|
index_type |
offset, |
|
|
int |
indent = 0 |
|
) |
| const |
|
inlineprivate |
An internal debug utility printing the internal structure of this sparse array to the given output stream.
Definition at line 1279 of file Brie.h.
1280 dump(detailed, out, *node.cell[
i].ptr, level - 1,
1282 }
else if (detailed) {
1285 out <<
times(
"\t", indent + 1) <<
i <<
": empty range " <<
low <<
" - " << hig <<
"\n";
1296 void dump(
bool detail =
false, std::ostream& out = std::cout)
const {
1298 out <<
" - empty - \n";
◆ empty()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Tests whether this sparse array is empty, thus it only contains default-values, or not.
Definition at line 509 of file Brie.h.
◆ end()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
An iterator referencing the position after the last non-default element.
Definition at line 1109 of file Brie.h.
◆ find() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
An operation to obtain an iterator referencing an element addressed by the given index.
If the corresponding element is a non-default value, a corresponding iterator will be returned. Otherwise end() will be returned.
Definition at line 1118 of file Brie.h.
Referenced by souffle::SparseBitMap< BITS >::end().
◆ find() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
An operation to obtain an iterator referencing an element addressed by the given index.
If the corresponding element is a non-default value, a corresponding iterator will be returned. Otherwise end() will be returned. A operation context can be provided for exploiting temporal locality.
Definition at line 1129 of file Brie.h.
1144 Node* next = node->cell[x].ptr;
1147 if (!next)
return end();
1154 ctxt.lastNode = node;
1164 return iterator(node, std::make_pair(
i, value));
◆ findFirst()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains the left-most leaf-node of the tree rooted by the given node with the given level.
Definition at line 1396 of file Brie.h.
1408 node->parent =
nullptr;
◆ freeNodes()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Destroys a node and all its sub-nodes recursively.
Definition at line 1339 of file Brie.h.
1347 if (node ==
nullptr) {
◆ get() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains a mutable reference to the value addressed by the given index.
- Parameters
-
i | the index of the element to be addressed |
- Returns
- a mutable reference to the corresponding element
Definition at line 744 of file Brie.h.
◆ get() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains a mutable reference to the value addressed by the given index.
- Parameters
-
i | the index of the element to be addressed |
ctxt | a operation context to exploit state-less temporal locality |
- Returns
- a mutable reference to the corresponding element
Definition at line 756 of file Brie.h.
◆ getAtomic() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains a mutable reference to the atomic value addressed by the given index.
- Parameters
-
i | the index of the element to be addressed |
- Returns
- a mutable reference to the corresponding element
Definition at line 766 of file Brie.h.
Referenced by souffle::SparseBitMap< BITS >::empty().
◆ getAtomic() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains a mutable reference to the atomic value addressed by the given index.
- Parameters
-
i | the index of the element to be addressed |
ctxt | a operation context to exploit state-less temporal locality |
- Returns
- a mutable reference to the corresponding element
Definition at line 778 of file Brie.h.
◆ getFirstInfo()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains a snapshot of the current first-node information.
Definition at line 694 of file Brie.h.
703 uintptr_t version = info.version;
706 if (!__sync_bool_compare_and_swap(&
synced.
first, (Node*)version, (Node*)(version + 1))) {
◆ getFirstVersion()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains the current version number of the first node information.
Definition at line 686 of file Brie.h.
◆ getIndex()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains the index within the arrays of cells of a given index on a given level of the internally maintained tree.
Definition at line 1498 of file Brie.h.
◆ getLeaf()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
An internal function capable of navigating to a given leaf node entry.
If the cell does not exist yet it will be created as a side-effect.
- Parameters
-
i | the index of the requested cell |
ctxt | a operation context to exploit state-less temporal locality |
- Returns
- a reference to the requested cell
Definition at line 791 of file Brie.h.
800 while (info.offset < firstInfo.offset) {
801 firstInfo.node = info.root;
802 firstInfo.offset = info.offset;
837 Node* node = info.root;
838 unsigned level = info.levels;
847 std::atomic<Node*>& aNext = node->cell[x].aptr;
852 newNext->parent = node;
855 if (!aNext.compare_exchange_strong(next, newNext)) {
871 while (off < first_info.offset) {
872 first_info.node = next;
873 first_info.offset = off;
893 ctxt.lastNode = node;
◆ getLevelMask()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Computes the bit-mask to be applicable to obtain the offset of a node on a given tree level.
Definition at line 1506 of file Brie.h.
◆ getMemoryUsage() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Computes the total memory usage of this data structure.
Definition at line 555 of file Brie.h.
◆ getMemoryUsage() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ getRootInfo()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains a snapshot of the current root information.
Definition at line 620 of file Brie.h.
636 uintptr_t version = info.version;
639 if (!__sync_bool_compare_and_swap(&
synced.
root, (Node*)version, (Node*)(version + 1))) {
◆ getRootVersion()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains the current version of the root.
Definition at line 612 of file Brie.h.
◆ inBoundaries() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Tests whether the given index is covered by the boundaries defined by the hight and offset of the internally maintained tree.
Definition at line 1481 of file Brie.h.
◆ inBoundaries() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Tests whether the given index is within the boundaries defined by the given tree hight and offset.
Definition at line 1489 of file Brie.h.
1491 if (level > (
sizeof(
index_type) * 8 / BITS))
return 0;
◆ lookup() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains the value associated to index i – which might be the default value of the covered type if the value hasn't been defined previously.
Definition at line 946 of file Brie.h.
◆ lookup() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains the value associated to index i – which might be the default value of the covered type if the value hasn't been defined previously.
A operation context can be provided for exploiting temporal locality.
Definition at line 957 of file Brie.h.
990 static void merge(
const Node* parent, Node*& trg,
const Node* src,
int levels) {
992 if (src ==
nullptr) {
◆ lowerBound() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ lowerBound() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
An operation obtaining the smallest non-default element such that it's index is >= the given index.
A operation context can be provided for exploiting temporal locality.
Definition at line 1196 of file Brie.h.
1207 Node* next = node->cell[x].ptr;
1213 node =
const_cast<Node*
>(node->parent);
1214 if (!node)
return end();
1221 i += 1ull << (BITS * level);
1226 return iterator(node, std::make_pair(
i, node->cell[x].value));
1252 if (
i == std::numeric_limits<index_type>::max()) {
◆ merge()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
A static operation utilized internally for merging sub-trees recursively.
- Parameters
-
parent | the parent node of the current merge operation |
trg | a reference to the pointer the cloned node should be stored to |
src | the node to be cloned |
levels | the height of the cloned node |
Definition at line 1006 of file Brie.h.
1011 trg->cell[
i].value = merg(trg->cell[
i].value, src->cell[
i].value);
1018 merge(trg, trg->cell[
i].ptr, src->cell[
i].ptr, levels - 1);
1028 if (other.empty()) {
◆ newNode()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Creates new nodes and initializes them with 0.
Definition at line 1332 of file Brie.h.
◆ operator=() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
An assignment creating a deep copy of the handed in array structure (utilizing the copy functor provided as a template parameter).
Definition at line 461 of file Brie.h.
◆ operator=() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
An assignment operation taking over ownership from a r-value reference to a sparse array.
Definition at line 485 of file Brie.h.
501 std::size_t
size()
const {
503 if (
empty())
return 0;
◆ operator[]()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Obtains the value associated to index i – which might be the default value of the covered type if the value hasn't been defined previously.
Definition at line 937 of file Brie.h.
◆ raiseLevel() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Raises the level of this tree by one level.
It does so by introducing a new root node and inserting the current root node as a child node.
Definition at line 1418 of file Brie.h.
1431 assert(info.levels < (
sizeof(
index_type) * 8 / BITS) + 1);
1435 newRoot->parent =
nullptr;
1439 newRoot->cell[x].ptr = info.root;
◆ raiseLevel() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Attempts to raise the height of this tree based on the given root node information and updates the root-info snapshot correspondingly.
Definition at line 1445 of file Brie.h.
1454 oldRoot->parent = info.root;
1475 return (a & mask) == offset;
◆ size()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Computes the number of non-empty elements within this sparse array.
Definition at line 517 of file Brie.h.
522 std::size_t res =
sizeof(Node);
◆ tryUpdateFirstInfo()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Updates the information stored regarding the first node in a concurrent setting utilizing a optimistic locking approach.
This is identical to the approach utilized for the root info.
Definition at line 717 of file Brie.h.
◆ tryUpdateRootInfo()
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Updates the current root information based on the handed in modified snapshot instance if the version number of the snapshot still corresponds to the current version.
Otherwise a concurrent update took place and the operation is aborted.
- Parameters
-
info | the updated information to be assigned to the active root-info data |
- Returns
- true if successfully updated, false if aborted
Definition at line 650 of file Brie.h.
◆ update() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Updates the value stored in cell i by the given value.
Definition at line 919 of file Brie.h.
◆ update() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
Updates the value stored in cell i by the given value.
A operation context can be provided for exploiting temporal locality.
Definition at line 928 of file Brie.h.
◆ upperBound() [1/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
An operation obtaining the smallest non-default element such that it's index is greater the given index.
Definition at line 1258 of file Brie.h.
◆ upperBound() [2/2]
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
An operation obtaining the smallest non-default element such that it's index is greater the given index.
A operation context can be provided for exploiting temporal locality.
Definition at line 1267 of file Brie.h.
1267 :
" << node.parent << " -- range:
" << offset << " -
"
1268 << (offset + ~getLevelMask(level + 1)) << "\n";
1271 for (int i = 0; i < NUM_CELLS; i++) {
1272 if (detailed || node.cell[i].value != value_type()) {
◆ detail::brie::SparseArrayIter
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
template<typename A >
◆ @1
◆ BIT_PER_STEP
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ INDEX_MASK
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ NUM_CELLS
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ synced
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
◆ unsynced
template<typename T , unsigned BITS = 6, typename merge_op = default_merge<T>, typename copy_op = identity<T>>
The documentation for this class was generated from the following file:
- include/souffle/datastructure/Brie.h
static Node * clone(const Node *node, int level)
Clones the given node and all its sub-nodes.
iterator find(index_type i) const
An operation to obtain an iterator referencing an element addressed by the given index.
iterator end() const
An iterator referencing the position after the last non-default element.
static void merge(const Node *parent, Node *&trg, const Node *src, int levels)
A static operation utilized internally for merging sub-trees recursively.
void update(index_type i, const value_type &val)
Updates the value stored in cell i by the given value.
static index_type getIndex(brie_element_type a, unsigned level)
Obtains the index within the arrays of cells of a given index on a given level of the internally main...
SparseArray()
A default constructor creating an empty sparse array.
static Node * findFirst(Node *node, int level)
Obtains the left-most leaf-node of the tree rooted by the given node with the given level.
iterator lowerBound(index_type i) const
An operation obtaining the smallest non-default element such that it's index is >= the given index.
SparseArrayIter< this_t > iterator
value_type & get(index_type i)
Obtains a mutable reference to the value addressed by the given index.
iterator upperBound(index_type i) const
An operation obtaining the smallest non-default element such that it's index is greater the given ind...
value_type lookup(index_type i) const
Obtains the value associated to index i – which might be the default value of the covered type if the...
std::size_t size() const
Computes the number of non-empty elements within this sparse array.
detail::multiplying_printer< T > times(const T &value, unsigned num)
A utility printing a given value multiple times.
static index_type getLevelMask(unsigned level)
Computes the bit-mask to be applicable to obtain the offset of a node on a given tree level.
void addAll(const SparseArray &other)
Adds all the values stored in the given array to this array.
static Node * newNode()
Creates new nodes and initializes them with 0.
FirstInfoSnapshot getFirstInfo() const
Obtains a snapshot of the current first-node information.
RamDomain brie_element_type
void raiseLevel()
Raises the level of this tree by one level.
static constexpr key_type INDEX_MASK
auto copy(span< A, arity > s)
bool inBoundaries(index_type a) const
Tests whether the given index is covered by the boundaries defined by the hight and offset of the int...
std::size_t getMemoryUsage() const
Computes the total memory usage of this data structure.
static constexpr int BIT_PER_STEP
iterator begin() const
Obtains an iterator referencing the first non-default element or end in case there are no such elemen...
static constexpr int NUM_CELLS
bool tryUpdateFirstInfo(const FirstInfoSnapshot &info)
Updates the information stored regarding the first node in a concurrent setting utilizing a optimisti...
void clean()
Conducts a cleanup of the internal tree structure.
RootInfoSnapshot getRootInfo() const
Obtains a snapshot of the current root information.
bool empty() const
Tests whether this sparse array is empty, thus it only contains default-values, or not.
void dump(bool detailed, std::ostream &out, const Node &node, int level, index_type offset, int indent=0) const
An internal debug utility printing the internal structure of this sparse array to the given output st...