summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-11-02 13:13:11 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-11-02 13:59:58 +0000
commit38f3c0c47d005fff498a4b7686492bf2640a3f69 (patch)
treed3051177001af8691cec9303b26c0cc68ef0dcf6
parent4677de8f0e2603078bd4c76e4e4fd4a621708124 (diff)
- deinline foreach in btree leaf nodes.
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoresaver.cpp1
-rw-r--r--searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/reference_mappings.cpp1
-rw-r--r--vespalib/src/vespa/vespalib/btree/btreenode.h39
-rw-r--r--vespalib/src/vespa/vespalib/btree/btreenode.hpp36
5 files changed, 48 insertions, 30 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoresaver.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoresaver.cpp
index 49d53aa38f0..ee5713c3c15 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoresaver.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoresaver.cpp
@@ -4,6 +4,7 @@
#include <vespa/searchlib/util/bufferwriter.h>
#include "document_meta_store_versions.h"
#include <vespa/searchlib/attribute/iattributesavetarget.h>
+#include <vespa/vespalib/btree/btreenode.hpp>
using vespalib::GenerationHandler;
using search::IAttributeSaveTarget;
diff --git a/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp b/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
index 2ac0e42cc79..62801e0b1ff 100644
--- a/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
+++ b/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
@@ -14,6 +14,7 @@
#include <vespa/searchcommon/attribute/config.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/test/insertion_operators.h>
+#include <vespa/vespalib/btree/btreenode.hpp>
#include <cinttypes>
#include <filesystem>
diff --git a/searchlib/src/vespa/searchlib/attribute/reference_mappings.cpp b/searchlib/src/vespa/searchlib/attribute/reference_mappings.cpp
index 89ab99754a5..18c6a9ba931 100644
--- a/searchlib/src/vespa/searchlib/attribute/reference_mappings.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/reference_mappings.cpp
@@ -4,6 +4,7 @@
#include "reference.h"
#include <vespa/vespalib/datastore/datastore.hpp>
#include <vespa/vespalib/btree/btreestore.hpp>
+#include <vespa/vespalib/btree/btreenode.hpp>
#include <vespa/vespalib/util/rcuvector.hpp>
namespace search::attribute {
diff --git a/vespalib/src/vespa/vespalib/btree/btreenode.h b/vespalib/src/vespa/vespalib/btree/btreenode.h
index f7e0b535b33..0e214eff83b 100644
--- a/vespalib/src/vespa/vespalib/btree/btreenode.h
+++ b/vespalib/src/vespa/vespalib/btree/btreenode.h
@@ -39,7 +39,7 @@ public:
static constexpr uint8_t LEAF_LEVEL = 0;
protected:
uint16_t _validSlots;
- BTreeNode(uint8_t level) noexcept
+ explicit BTreeNode(uint8_t level) noexcept
: _level(level),
_isFrozen(false),
_validSlots(0)
@@ -161,7 +161,7 @@ class BTreeNodeAggregatedWrap<NoAggregated>
static NoAggregated _instance;
public:
- BTreeNodeAggregatedWrap() noexcept {}
+ BTreeNodeAggregatedWrap() noexcept = default;
NoAggregated &getAggregated() { return _instance; }
const NoAggregated &getAggregated() const { return _instance; }
@@ -174,7 +174,7 @@ template <typename KeyT, uint32_t NumSlots>
class BTreeNodeT : public BTreeNode {
protected:
KeyT _keys[NumSlots];
- BTreeNodeT(uint8_t level) noexcept
+ explicit BTreeNodeT(uint8_t level) noexcept
: BTreeNode(level),
_keys()
{}
@@ -247,7 +247,7 @@ public:
using DataWrapType::setData;
using DataWrapType::copyData;
protected:
- BTreeNodeTT(uint8_t level) noexcept
+ explicit BTreeNodeTT(uint8_t level) noexcept
: ParentType(level),
DataWrapType()
{}
@@ -490,44 +490,23 @@ public:
const DataT &getLastData() const { return this->getData(validSlots() - 1); }
void writeData(uint32_t idx, const DataT &data) { this->setData(idx, data); }
- uint32_t validLeaves() const { return validSlots(); }
+ uint32_t validLeaves() const noexcept { return validSlots(); }
template <typename FunctionType>
- void foreach_key(FunctionType func) const {
- const KeyT *it = _keys;
- const KeyT *ite = it + _validSlots;
- for (; it != ite; ++it) {
- func(*it);
- }
- }
+ void foreach_key(FunctionType func) const;
/**
* Call func with leaf entry key value as argument for leaf entries [start_idx, end_idx).
*/
template <typename FunctionType>
- void foreach_key_range(uint32_t start_idx, uint32_t end_idx, FunctionType func) const {
- const KeyT *it = _keys;
- const KeyT *ite = it + end_idx;
- it += start_idx;
- for (; it != ite; ++it) {
- func(*it);
- }
- }
+ void foreach_key_range(uint32_t start_idx, uint32_t end_idx, FunctionType func) const;
template <typename FunctionType>
- void foreach(FunctionType func) const {
- const KeyT *it = _keys;
- const KeyT *ite = it + _validSlots;
- uint32_t idx = 0;
- for (; it != ite; ++it) {
- func(*it, this->getData(idx++));
- }
- }
+ void foreach(FunctionType func) const;
};
-template <typename KeyT, typename DataT, typename AggrT,
- uint32_t NumSlots = 16>
+template <typename KeyT, typename DataT, typename AggrT, uint32_t NumSlots = 16>
class BTreeLeafNodeTemp : public BTreeLeafNode<KeyT, DataT, AggrT, NumSlots>
{
public:
diff --git a/vespalib/src/vespa/vespalib/btree/btreenode.hpp b/vespalib/src/vespa/vespalib/btree/btreenode.hpp
index ab33fd2c059..52e83dd6f72 100644
--- a/vespalib/src/vespa/vespalib/btree/btreenode.hpp
+++ b/vespalib/src/vespa/vespalib/btree/btreenode.hpp
@@ -376,4 +376,40 @@ BTreeLeafNode(const KeyDataType *smallArray, uint32_t arraySize) noexcept
freeze();
}
+
+template <typename KeyT, typename DataT, typename AggrT, uint32_t NumSlots>
+template <typename FunctionType>
+void BTreeLeafNode<KeyT, DataT, AggrT, NumSlots>::foreach_key(FunctionType func) const {
+ const KeyT *it = _keys;
+ const KeyT *ite = it + _validSlots;
+ for (; it != ite; ++it) {
+ func(*it);
+ }
+}
+
+/**
+ * Call func with leaf entry key value as argument for leaf entries [start_idx, end_idx).
+ */
+template <typename KeyT, typename DataT, typename AggrT, uint32_t NumSlots>
+template <typename FunctionType>
+void BTreeLeafNode<KeyT, DataT, AggrT, NumSlots>::foreach_key_range(uint32_t start_idx, uint32_t end_idx, FunctionType func) const {
+ const KeyT *it = _keys;
+ const KeyT *ite = it + end_idx;
+ it += start_idx;
+ for (; it != ite; ++it) {
+ func(*it);
+ }
+}
+
+template <typename KeyT, typename DataT, typename AggrT, uint32_t NumSlots>
+template <typename FunctionType>
+void BTreeLeafNode<KeyT, DataT, AggrT, NumSlots>::foreach(FunctionType func) const {
+ const KeyT *it = _keys;
+ const KeyT *ite = it + _validSlots;
+ uint32_t idx = 0;
+ for (; it != ite; ++it) {
+ func(*it, this->getData(idx++));
+ }
+}
+
}