aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-04-26 00:50:30 +0200
committerGitHub <noreply@github.com>2024-04-26 00:50:30 +0200
commit179a5b3441f5f838c1e9de5b3e575fabce3445cf (patch)
tree645caa5c51d48a63baff1abc47b946870360806b
parentd65bd0e4eb88649ddaed6238bb00d88a4f47993f (diff)
parent2e8a79cab1fbb534f06ba23db6686810c3ecaf91 (diff)
Merge pull request #31044 from vespa-engine/balder/add-noexcept-4
Add noexcept
-rw-r--r--vespalib/src/vespa/vespalib/btree/btreeiterator.h115
-rw-r--r--vespalib/src/vespa/vespalib/btree/btreeiterator.hpp164
2 files changed, 116 insertions, 163 deletions
diff --git a/vespalib/src/vespa/vespalib/btree/btreeiterator.h b/vespalib/src/vespa/vespalib/btree/btreeiterator.h
index a0d189ef03c..505ad4c5c3b 100644
--- a/vespalib/src/vespa/vespalib/btree/btreeiterator.h
+++ b/vespalib/src/vespa/vespalib/btree/btreeiterator.h
@@ -39,7 +39,7 @@ class NodeElement
using DataType = typename NodeType::DataType;
uint64_t _nodeAndIdx;
- NodeType * getWNode() const { return const_cast<NodeType *>(getNode()); }
+ NodeType * getWNode() const noexcept { return const_cast<NodeType *>(getNode()); }
static constexpr uint8_t NODE_BITS = 57;
static constexpr uint8_t IDX_BITS = 64 - NODE_BITS;
static constexpr uint64_t NODE_MASK = (1ul << NODE_BITS) - 1ul;
@@ -162,12 +162,12 @@ private:
/*
* Find the next leaf node, called by operator++() as needed.
*/
- void findNextLeafNode();
+ void findNextLeafNode() noexcept;
/*
* Find the previous leaf node, called by operator--() as needed.
*/
- void findPrevLeafNode();
+ void findPrevLeafNode() noexcept;
protected:
/*
@@ -175,7 +175,7 @@ protected:
*
* @param pidx Number of levels above leaf nodes to take into account.
*/
- size_t position(uint32_t pidx) const;
+ size_t position(uint32_t pidx) const noexcept;
/**
* Create iterator pointing to first element in the tree referenced
@@ -184,7 +184,7 @@ protected:
* @param root Reference to root of tree
* @param allocator B-tree node allocator helper class.
*/
- BTreeIteratorBase(BTreeNode::Ref root, const NodeAllocatorType &allocator);
+ BTreeIteratorBase(BTreeNode::Ref root, const NodeAllocatorType &allocator) noexcept;
/**
* Compability constructor, creating a temporary tree with only a
@@ -204,7 +204,7 @@ protected:
/**
* Step iterator forwards. If at end then leave it at end.
*/
- BTreeIteratorBase & operator++() {
+ BTreeIteratorBase & operator++() noexcept {
if (_leaf.getNode() == nullptr) {
return *this;
}
@@ -220,7 +220,7 @@ protected:
* Step iterator backwards. If at end then place it at last valid
* position in tree (cf. rbegin())
*/
- BTreeIteratorBase & operator--() {
+ BTreeIteratorBase & operator--() noexcept {
if (_leaf.getNode() == nullptr) {
rbegin();
return *this;
@@ -233,17 +233,17 @@ protected:
return *this;
}
- void set_subtree_position(const InternalNodeType* node, uint32_t level, uint32_t idx, size_t position);
+ void set_subtree_position(const InternalNodeType* node, uint32_t level, uint32_t idx, size_t position) noexcept;
/*
* Step iterator forwards the given number of steps.
*/
- void step_forward(size_t steps);
+ void step_forward(size_t steps) noexcept;
/*
* Step iterator backwards the given number of steps.
*/
- void step_backward(size_t steps);
+ void step_backward(size_t steps) noexcept;
~BTreeIteratorBase();
BTreeIteratorBase(const BTreeIteratorBase &other);
@@ -256,7 +256,7 @@ protected:
*
* @param pathSize New tree height (number of levels of internal nodes)
*/
- void clearPath(uint32_t pathSize);
+ void clearPath(uint32_t pathSize) noexcept;
/**
* Call func with leaf entry key value as argument for all leaf entries in subtree
@@ -347,12 +347,12 @@ public:
/**
* Return the current position in the tree.
*/
- size_t position() const { return position(_pathSize); }
+ size_t position() const noexcept { return position(_pathSize); }
/**
* Return the distance between two positions in the tree.
*/
- ssize_t operator-(const BTreeIteratorBase &rhs) const;
+ ssize_t operator-(const BTreeIteratorBase &rhs) const noexcept;
/**
* Return if the tree has data or not (e.g. keys and data or only keys).
@@ -362,12 +362,14 @@ public:
/**
* Move the iterator directly to end. Used by findHelper method in BTree.
*/
- void setupEnd();
+ void setupEnd() noexcept {
+ _leaf.invalidate();
+ }
/**
* Setup iterator to be empty and not be associated with any tree.
*/
- void setupEmpty() {
+ void setupEmpty() noexcept {
clearPath(0u);
_leaf.invalidate();
_leafRoot = nullptr;
@@ -376,44 +378,43 @@ public:
/**
* Move iterator to beyond last element in the current tree.
*/
- void end() __attribute__((noinline));
+ void end() noexcept __attribute__((noinline));
/**
* Move iterator to beyond last element in the given tree.
*
* @param rootRef Reference to root of tree.
*/
- void end(BTreeNode::Ref rootRef);
+ void end(BTreeNode::Ref rootRef) noexcept;
/**
* Move iterator to first element in the current tree.
*/
- void begin();
+ void begin() noexcept;
/**
* Move iterator to first element in the given tree.
*
* @param rootRef Reference to root of tree.
*/
- void begin(BTreeNode::Ref rootRef);
+ void begin(BTreeNode::Ref rootRef) noexcept;
/**
* Move iterator to last element in the current tree.
*/
- void rbegin();
+ void rbegin() noexcept;
/*
* Get aggregated values for the current tree.
*/
- const AggrT & getAggregated() const;
+ const AggrT & getAggregated() const noexcept;
- bool identical(const BTreeIteratorBase &rhs) const;
+ bool identical(const BTreeIteratorBase &rhs) const noexcept;
template <typename FunctionType>
- void foreach_key(FunctionType func) const {
+ void foreach_key(FunctionType func) const noexcept {
if (_pathSize > 0) {
- _path[_pathSize - 1].getNode()->
- foreach_key(_allocator->getNodeStore(), func);
+ _path[_pathSize - 1].getNode()->foreach_key(_allocator->getNodeStore(), func);
} else if (_leafRoot != nullptr) {
_leafRoot->foreach_key(func);
}
@@ -425,7 +426,7 @@ public:
* range [this iterator, end_itr)).
*/
template <typename FunctionType>
- void foreach_key_range(const BTreeIteratorBase &end_itr, FunctionType func) const {
+ void foreach_key_range(const BTreeIteratorBase &end_itr, FunctionType func) const noexcept {
if (!valid()) {
return;
}
@@ -536,7 +537,7 @@ public:
* @param root Reference to root of tree
* @param allocator B-tree node allocator helper class.
*/
- BTreeConstIterator(BTreeNode::Ref root, const NodeAllocatorType &allocator)
+ BTreeConstIterator(BTreeNode::Ref root, const NodeAllocatorType &allocator) noexcept
: ParentType(root, allocator)
{
}
@@ -562,7 +563,7 @@ public:
/**
* Step iterator forwards. If at end then leave it at end.
*/
- BTreeConstIterator & operator++() {
+ BTreeConstIterator & operator++() noexcept {
ParentType::operator++();
return *this;
}
@@ -571,7 +572,7 @@ public:
* Step iterator backwards. If at end then place it at last valid
* position in tree (cf. rbegin())
*/
- BTreeConstIterator & operator--() {
+ BTreeConstIterator & operator--() noexcept {
ParentType::operator--();
return *this;
}
@@ -579,7 +580,7 @@ public:
/*
* Step iterator forwards the given number of steps.
*/
- BTreeConstIterator & operator+=(size_t steps) {
+ BTreeConstIterator & operator+=(size_t steps) noexcept {
step_forward(steps);
return *this;
}
@@ -587,7 +588,7 @@ public:
/*
* Step iterator backward the given number of steps.
*/
- BTreeConstIterator & operator-=(size_t steps) {
+ BTreeConstIterator & operator-=(size_t steps) noexcept {
step_backward(steps);
return *this;
}
@@ -599,7 +600,7 @@ public:
* @param key Key to search for
* @param comp Comparator for the tree ordering.
*/
- void lower_bound(const KeyType & key, CompareT comp = CompareT());
+ void lower_bound(const KeyType & key, CompareT comp = CompareT()) noexcept;
/**
* Position iterator at first position with a key that is greater
@@ -608,7 +609,7 @@ public:
* @param key Key to search for
* @param comp Comparator for the tree ordering.
*/
- void lower_bound(BTreeNode::Ref rootRef, const KeyType & key, CompareT comp = CompareT());
+ void lower_bound(BTreeNode::Ref rootRef, const KeyType & key, CompareT comp = CompareT()) noexcept;
/**
* Step iterator forwards until it is at a position with a key
@@ -621,7 +622,7 @@ public:
* @param key Key to search for
* @param comp Comparator for the tree ordering.
*/
- void seek(const KeyType &key, CompareT comp = CompareT());
+ void seek(const KeyType &key, CompareT comp = CompareT()) noexcept;
/**
* Step iterator forwards until it is at a position with a key
@@ -633,7 +634,7 @@ public:
* @param key Key to search for
* @param comp Comparator for the tree ordering.
*/
- void binarySeek(const KeyType &key, CompareT comp = CompareT());
+ void binarySeek(const KeyType &key, CompareT comp = CompareT()) noexcept;
/**
* Step iterator forwards until it is at a position with a key
@@ -645,7 +646,7 @@ public:
* @param key Key to search for
* @param comp Comparator for the tree ordering.
*/
- void linearSeek(const KeyType &key, CompareT comp = CompareT());
+ void linearSeek(const KeyType &key, CompareT comp = CompareT()) noexcept;
/**
* Step iterator forwards until it is at a position with a key
@@ -658,7 +659,7 @@ public:
* @param key Key to search for
* @param comp Comparator for the tree ordering.
*/
- void seekPast(const KeyType &key, CompareT comp = CompareT());
+ void seekPast(const KeyType &key, CompareT comp = CompareT()) noexcept;
/**
* Step iterator forwards until it is at a position with a key
@@ -670,7 +671,7 @@ public:
* @param key Key to search for
* @param comp Comparator for the tree ordering.
*/
- void binarySeekPast(const KeyType &key, CompareT comp = CompareT());
+ void binarySeekPast(const KeyType &key, CompareT comp = CompareT()) noexcept;
/**
* Step iterator forwards until it is at a position with a key
@@ -682,7 +683,7 @@ public:
* @param key Key to search for
* @param comp Comparator for the tree ordering.
*/
- void linearSeekPast(const KeyType &key, CompareT comp = CompareT());
+ void linearSeekPast(const KeyType &key, CompareT comp = CompareT()) noexcept;
/**
* Validate the iterator as a valid iterator or positioned at
@@ -692,7 +693,7 @@ public:
* @param rootRef Reference to root of tree to operate on
* @param comp Comparator for the tree ordering.
*/
- void validate(BTreeNode::Ref rootRef, CompareT comp = CompareT());
+ void validate(BTreeNode::Ref rootRef, CompareT comp = CompareT()) noexcept;
};
@@ -737,7 +738,7 @@ public:
using ParentType::step_forward;
using EntryRef = datastore::EntryRef;
- BTreeIterator(BTreeNode::Ref root, const NodeAllocatorType &allocator)
+ BTreeIterator(BTreeNode::Ref root, const NodeAllocatorType &allocator) noexcept
: ParentType(root, allocator)
{
}
@@ -751,29 +752,29 @@ public:
{
}
- BTreeIterator() : ParentType() { }
+ BTreeIterator() noexcept : ParentType() { }
- BTreeIterator & operator++() {
+ BTreeIterator & operator++() noexcept {
ParentType::operator++();
return *this;
}
- BTreeIterator & operator--() {
+ BTreeIterator & operator--() noexcept {
ParentType::operator--();
return *this;
}
- BTreeIterator & operator+=(size_t steps) {
+ BTreeIterator & operator+=(size_t steps) noexcept {
step_forward(steps);
return *this;
}
- BTreeIterator & operator-=(size_t steps) {
+ BTreeIterator & operator-=(size_t steps) noexcept {
step_backward(steps);
return *this;
}
- NodeAllocatorType & getAllocator() const {
+ NodeAllocatorType & getAllocator() const noexcept {
return const_cast<NodeAllocatorType &>(*_allocator);
}
@@ -781,19 +782,19 @@ public:
void moveNextLeafNode();
- void writeData(const DataType &data) {
+ void writeData(const DataType &data) noexcept {
_leaf.getWNode()->writeData(_leaf.getIdx(), data);
}
// Only use during compaction when changing reference to moved value
- DataType &getWData() { return _leaf.getWData(); }
+ DataType &getWData() noexcept { return _leaf.getWData(); }
/**
* Set a new key for the current iterator position.
* The new key must have the same semantic meaning as the old key.
* Typically used when compacting data store containing keys.
*/
- void writeKey(const KeyType &key);
+ void writeKey(const KeyType &key) noexcept;
/**
* Updata data at the current iterator position. The tree should
@@ -803,7 +804,7 @@ public:
* @param aggrCalc Calculator for updating aggregated information.
*/
template <class AggrCalcT>
- void updateData(const DataType &data, const AggrCalcT &aggrCalc);
+ void updateData(const DataType &data, const AggrCalcT &aggrCalc) noexcept;
/**
* Thaw a path from the root node down the the current leaf node in
@@ -816,12 +817,12 @@ private:
/* Insert into empty tree */
template <class AggrCalcT>
BTreeNode::Ref insertFirst(const KeyType &key, const DataType &data, const AggrCalcT &aggrCalc);
- LeafNodeType * getLeafNode() const { return _leaf.getWNode(); }
- bool setLeafNodeIdx(uint32_t idx, const LeafNodeType *splitLeafNode);
- void setLeafNodeIdx(uint32_t idx) { _leaf.setIdx(idx); }
- uint32_t getLeafNodeIdx() const { return _leaf.getIdx(); }
- uint32_t getPathSize() const { return _pathSize; }
- PathElement & getPath(uint32_t pidx) { return _path[pidx]; }
+ LeafNodeType * getLeafNode() const noexcept { return _leaf.getWNode(); }
+ bool setLeafNodeIdx(uint32_t idx, const LeafNodeType *splitLeafNode) noexcept;
+ void setLeafNodeIdx(uint32_t idx) noexcept { _leaf.setIdx(idx); }
+ uint32_t getLeafNodeIdx() const noexcept { return _leaf.getIdx(); }
+ uint32_t getPathSize() const noexcept { return _pathSize; }
+ PathElement & getPath(uint32_t pidx) noexcept { return _path[pidx]; }
template <class AggrCalcT>
BTreeNode::Ref addLevel(BTreeNode::Ref rootRef, BTreeNode::Ref splitNodeRef, bool inRightSplit, const AggrCalcT &aggrCalc);
diff --git a/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp b/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp
index bdca5e2c4ff..e1196d7c6db 100644
--- a/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp
+++ b/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp
@@ -52,7 +52,7 @@ template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
void
BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-clearPath(uint32_t pathSize)
+clearPath(uint32_t pathSize) noexcept
{
uint32_t level = _pathSize;
while (level > pathSize) {
@@ -84,18 +84,7 @@ BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::~B
template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
void
-BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-setupEnd()
-{
- _leaf.invalidate();
-}
-
-
-template <typename KeyT, typename DataT, typename AggrT,
- uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
-void
-BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-end()
+BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::end() noexcept
{
if (_pathSize == 0) {
if (_leafRoot == nullptr)
@@ -126,8 +115,7 @@ end()
template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
void
-BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-end(BTreeNode::Ref rootRef)
+BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::end(BTreeNode::Ref rootRef) noexcept
{
if (!rootRef.valid()) {
setupEmpty();
@@ -167,7 +155,7 @@ template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
void
BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-findNextLeafNode()
+findNextLeafNode() noexcept
{
uint32_t pidx;
for (pidx = 0; pidx < _pathSize; ++pidx) {
@@ -195,7 +183,7 @@ template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
void
BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-findPrevLeafNode()
+findPrevLeafNode() noexcept
{
uint32_t pidx;
for (pidx = 0; pidx < _pathSize; ++pidx) {
@@ -225,8 +213,7 @@ findPrevLeafNode()
template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
void
-BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-begin()
+BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::begin() noexcept
{
uint32_t pidx = _pathSize;
if (pidx > 0u) {
@@ -251,8 +238,7 @@ begin()
template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
void
-BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-begin(BTreeNode::Ref rootRef)
+BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::begin(BTreeNode::Ref rootRef) noexcept
{
if (!rootRef.valid()) {
setupEmpty();
@@ -288,8 +274,7 @@ begin(BTreeNode::Ref rootRef)
template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
void
-BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-rbegin()
+BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::rbegin() noexcept
{
uint32_t pidx = _pathSize;
if (pidx > 0u) {
@@ -310,10 +295,7 @@ rbegin()
const LeafNodeType *lnode(_allocator->mapLeafRef(node));
_leaf.setNodeAndIdx(lnode, lnode->validSlots() - 1);
} else {
- _leaf.setNodeAndIdx(_leafRoot,
- (_leafRoot != nullptr) ?
- _leafRoot->validSlots() - 1 :
- 0u);
+ _leaf.setNodeAndIdx(_leafRoot, (_leafRoot != nullptr) ? _leafRoot->validSlots() - 1 : 0u);
}
}
@@ -322,7 +304,7 @@ template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
const AggrT &
BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-getAggregated() const
+getAggregated() const noexcept
{
// XXX: Undefined behavior if tree is empty.
uint32_t pidx = _pathSize;
@@ -340,7 +322,7 @@ template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
size_t
BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-position(uint32_t levels) const
+position(uint32_t levels) const noexcept
{
assert(_pathSize >= levels);
if (_leaf.getNode() == nullptr)
@@ -393,8 +375,7 @@ position(uint32_t levels) const
template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-BTreeIteratorBase(BTreeNode::Ref root,
- const NodeAllocatorType &allocator)
+BTreeIteratorBase(BTreeNode::Ref root, const NodeAllocatorType &allocator) noexcept
: _leaf(nullptr, 0u),
_path(),
_pathSize(0),
@@ -467,7 +448,7 @@ template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
ssize_t
BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-operator-(const BTreeIteratorBase &rhs) const
+operator-(const BTreeIteratorBase &rhs) const noexcept
{
if (_leaf.getNode() == nullptr) {
if (rhs._leaf.getNode() == nullptr)
@@ -497,7 +478,7 @@ template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
bool
BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-identical(const BTreeIteratorBase &rhs) const
+identical(const BTreeIteratorBase &rhs) const noexcept
{
if (_pathSize != rhs._pathSize || _leaf != rhs._leaf) {
HDR_ABORT("should not be reached");
@@ -518,7 +499,7 @@ template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
void
BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-set_subtree_position(const InternalNodeType* node, uint32_t level, uint32_t idx, size_t position)
+set_subtree_position(const InternalNodeType* node, uint32_t level, uint32_t idx, size_t position) noexcept
{
/*
* Walk down subtree adjusting iterator for new partial position.
@@ -550,7 +531,7 @@ template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
void
BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-step_forward(size_t steps)
+step_forward(size_t steps) noexcept
{
auto lnode = _leaf.getNode();
if (lnode == nullptr) {
@@ -600,8 +581,7 @@ step_forward(size_t steps)
template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
void
-BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-step_backward(size_t steps)
+BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::step_backward(size_t steps) noexcept
{
int64_t remaining_steps = steps;
if (remaining_steps == 0) {
@@ -651,11 +631,10 @@ step_backward(size_t steps)
set_subtree_position(node, level, idx, -remaining_steps);
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
BTreeConstIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-lower_bound(const KeyType & key, CompareT comp)
+lower_bound(const KeyType & key, CompareT comp) noexcept
{
if (_pathSize == 0) {
if (_leafRoot == nullptr)
@@ -696,11 +675,10 @@ lower_bound(const KeyType & key, CompareT comp)
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
BTreeConstIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-lower_bound(BTreeNode::Ref rootRef, const KeyType & key, CompareT comp)
+lower_bound(BTreeNode::Ref rootRef, const KeyType & key, CompareT comp) noexcept
{
if (!rootRef.valid()) {
setupEmpty();
@@ -748,11 +726,10 @@ lower_bound(BTreeNode::Ref rootRef, const KeyType & key, CompareT comp)
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
BTreeConstIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-seek(const KeyType & key, CompareT comp)
+seek(const KeyType & key, CompareT comp) noexcept
{
if (TraitsT::BINARY_SEEK) {
binarySeek(key, comp);
@@ -761,11 +738,10 @@ seek(const KeyType & key, CompareT comp)
}
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
BTreeConstIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-binarySeek(const KeyType & key, CompareT comp)
+binarySeek(const KeyType & key, CompareT comp) noexcept
{
const LeafNodeType *lnode = _leaf.getNode();
uint32_t lidx = _leaf.getIdx() + 1;
@@ -806,11 +782,10 @@ binarySeek(const KeyType & key, CompareT comp)
_leaf.setIdx(lidx);
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
BTreeConstIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-linearSeek(const KeyType & key, CompareT comp)
+linearSeek(const KeyType & key, CompareT comp) noexcept
{
const LeafNodeType *lnode = _leaf.getNode();
uint32_t lidx = _leaf.getIdx() + 1;
@@ -858,11 +833,10 @@ linearSeek(const KeyType & key, CompareT comp)
_leaf.setIdx(lidx);
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
BTreeConstIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-seekPast(const KeyType & key, CompareT comp)
+seekPast(const KeyType & key, CompareT comp) noexcept
{
if (TraitsT::BINARY_SEEK) {
binarySeekPast(key, comp);
@@ -871,11 +845,10 @@ seekPast(const KeyType & key, CompareT comp)
}
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
BTreeConstIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-binarySeekPast(const KeyType & key, CompareT comp)
+binarySeekPast(const KeyType & key, CompareT comp) noexcept
{
const LeafNodeType *lnode = _leaf.getNode();
uint32_t lidx = _leaf.getIdx() + 1;
@@ -916,11 +889,10 @@ binarySeekPast(const KeyType & key, CompareT comp)
_leaf.setIdx(lidx);
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
BTreeConstIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-linearSeekPast(const KeyType & key, CompareT comp)
+linearSeekPast(const KeyType & key, CompareT comp) noexcept
{
const LeafNodeType *lnode = _leaf.getNode();
uint32_t lidx = _leaf.getIdx() + 1;
@@ -970,11 +942,10 @@ linearSeekPast(const KeyType & key, CompareT comp)
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
BTreeConstIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-validate(BTreeNode::Ref rootRef, CompareT comp)
+validate(BTreeNode::Ref rootRef, CompareT comp) noexcept
{
bool frozen = false;
if (!rootRef.valid()) {
@@ -1036,8 +1007,7 @@ validate(BTreeNode::Ref rootRef, CompareT comp)
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
BTreeNode::Ref
BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
moveFirstLeafNode(BTreeNode::Ref rootRef)
@@ -1100,11 +1070,9 @@ moveFirstLeafNode(BTreeNode::Ref rootRef)
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
-BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-moveNextLeafNode()
+BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::moveNextLeafNode()
{
uint32_t level = 0;
uint32_t levels = _pathSize;
@@ -1146,11 +1114,9 @@ moveNextLeafNode()
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
-BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-writeKey(const KeyType & key)
+BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::writeKey(const KeyType & key) noexcept
{
LeafNodeType * lnode = getLeafNode();
lnode->writeKey(_leaf.getIdx(), key);
@@ -1170,12 +1136,11 @@ writeKey(const KeyType & key)
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
template <class AggrCalcT>
void
BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-updateData(const DataType & data, [[maybe_unused]] const AggrCalcT &aggrCalc)
+updateData(const DataType & data, [[maybe_unused]] const AggrCalcT &aggrCalc) noexcept
{
LeafNodeType * lnode = getLeafNode();
if constexpr (AggrCalcT::hasAggregated() && AggrCalcT::aggregate_over_values()) {
@@ -1198,8 +1163,7 @@ updateData(const DataType & data, [[maybe_unused]] const AggrCalcT &aggrCalc)
const PathElement & pe = _path[i];
InternalNodeType * inode = pe.getWNode();
AggrT oldpa(inode->getAggregated());
- if (aggrCalc.update(inode->getAggregated(),
- oldca, ca)) {
+ if (aggrCalc.update(inode->getAggregated(), oldca, ca)) {
Aggregator::recalc(*inode, *_allocator, aggrCalc);
}
AggrT pa(inode->getAggregated());
@@ -1212,11 +1176,9 @@ updateData(const DataType & data, [[maybe_unused]] const AggrCalcT &aggrCalc)
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
BTreeNode::Ref
-BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-thaw(BTreeNode::Ref rootRef)
+BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::thaw(BTreeNode::Ref rootRef)
{
assert(_leaf.getNode() != nullptr && _compatLeafNode.get() == nullptr);
if (!_leaf.getNode()->getFrozen())
@@ -1226,20 +1188,17 @@ thaw(BTreeNode::Ref rootRef)
LeafNodeType *leafNode = allocator.mapLeafRef(rootRef);
assert(leafNode == _leaf.getNode());
assert(leafNode == _leafRoot);
- LeafNodeTypeRefPair thawedLeaf = allocator.thawNode(rootRef,
- leafNode);
+ LeafNodeTypeRefPair thawedLeaf = allocator.thawNode(rootRef, leafNode);
_leaf.setNode(thawedLeaf.data);
_leafRoot = thawedLeaf.data;
return thawedLeaf.ref;
}
assert(_leafRoot == nullptr);
- assert(_path[_pathSize - 1].getNode() ==
- allocator.mapInternalRef(rootRef));
+ assert(_path[_pathSize - 1].getNode() == allocator.mapInternalRef(rootRef));
BTreeNode::Ref childRef(_path[0].getNode()->getChild(_path[0].getIdx()));
LeafNodeType *leafNode = allocator.mapLeafRef(childRef);
assert(leafNode == _leaf.getNode());
- LeafNodeTypeRefPair thawedLeaf = allocator.thawNode(childRef,
- leafNode);
+ LeafNodeTypeRefPair thawedLeaf = allocator.thawNode(childRef, leafNode);
_leaf.setNode(thawedLeaf.data);
childRef = thawedLeaf.ref;
uint32_t level = 0;
@@ -1247,10 +1206,9 @@ thaw(BTreeNode::Ref rootRef)
while (level < levels) {
PathElement &pe = _path[level];
InternalNodeType *node(pe.getWNode());
- BTreeNode::Ref nodeRef = level + 1 < levels ?
- _path[level + 1].getNode()->
- getChild(_path[level + 1].getIdx()) :
- rootRef;
+ BTreeNode::Ref nodeRef = (level + 1 < levels)
+ ? _path[level + 1].getNode()->getChild(_path[level + 1].getIdx())
+ : rootRef;
assert(node == allocator.mapInternalRef(nodeRef));
if (!node->getFrozen()) {
node->set_child_relaxed(pe.getIdx(), childRef);
@@ -1267,8 +1225,7 @@ thaw(BTreeNode::Ref rootRef)
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
template <class AggrCalcT>
BTreeNode::Ref
BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
@@ -1295,16 +1252,14 @@ insertFirst(const KeyType &key, const DataType &data,
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
bool
BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
-setLeafNodeIdx(uint32_t idx, const LeafNodeType *splitLeafNode)
+setLeafNodeIdx(uint32_t idx, const LeafNodeType *splitLeafNode) noexcept
{
uint32_t leafSlots = _leaf.getNode()->validSlots();
if (idx >= leafSlots) {
- _leaf.setNodeAndIdx(splitLeafNode,
- idx - leafSlots);
+ _leaf.setNodeAndIdx(splitLeafNode, idx - leafSlots);
if (_pathSize == 0) {
_leafRoot = splitLeafNode;
}
@@ -1316,8 +1271,7 @@ setLeafNodeIdx(uint32_t idx, const LeafNodeType *splitLeafNode)
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
template <class AggrCalcT>
BTreeNode::Ref
BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
@@ -1349,8 +1303,7 @@ addLevel(BTreeNode::Ref rootRef, BTreeNode::Ref splitNodeRef,
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
BTreeNode::Ref
BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
removeLevel(BTreeNode::Ref rootRef, InternalNodeType *rootNode)
@@ -1367,8 +1320,7 @@ removeLevel(BTreeNode::Ref rootRef, InternalNodeType *rootNode)
}
-template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
- typename TraitsT>
+template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT>
void
BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::
removeLast(BTreeNode::Ref rootRef)