diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-09-04 20:25:33 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-09-04 20:25:33 +0000 |
commit | 87253fbc538f8935d9483e0a5b8aac4201cecd7a (patch) | |
tree | 7fe0ff3116fe19062c13781280b663e96136a8a0 /storage | |
parent | f80e2f3bec9276ca37ec2c9328de02b557e9e7d4 (diff) |
Find index and store it in ActiveCopy.
Diffstat (limited to 'storage')
4 files changed, 20 insertions, 5 deletions
diff --git a/storage/src/vespa/storage/bucketdb/bucketinfo.h b/storage/src/vespa/storage/bucketdb/bucketinfo.h index 9c024c31fd3..665beefe598 100644 --- a/storage/src/vespa/storage/bucketdb/bucketinfo.h +++ b/storage/src/vespa/storage/bucketdb/bucketinfo.h @@ -86,6 +86,7 @@ public: * Returns the bucket copy struct for the given node, null if nonexisting */ const BucketCopy* getNode(uint16_t node) const noexcept; + uint16_t getRef(uint16_t node) const noexcept; /** * Returns the number of nodes this entry has. diff --git a/storage/src/vespa/storage/bucketdb/bucketinfo.hpp b/storage/src/vespa/storage/bucketdb/bucketinfo.hpp index a8a1069d587..d6e99bd3934 100644 --- a/storage/src/vespa/storage/bucketdb/bucketinfo.hpp +++ b/storage/src/vespa/storage/bucketdb/bucketinfo.hpp @@ -144,6 +144,17 @@ BucketInfoBase<NodeSeq>::getNode(uint16_t node) const noexcept { return &n; } } + return nullptr; +} + +template <typename NodeSeq> +uint16_t +BucketInfoBase<NodeSeq>::getRef(uint16_t node) const noexcept { + for (const auto& n : _nodes) { + if (n.getNode() == node) { + return &n - &_nodes[0]; + } + } return 0; } @@ -221,7 +232,7 @@ BucketInfoBase<NodeSeq>::operator==(const BucketInfoBase<NodeSeq>& other) const return false; } - if (!(_nodes[i] == other._nodes[i])) { + if (_nodes[i] != other._nodes[i]) { return false; } } diff --git a/storage/src/vespa/storage/distributor/activecopy.cpp b/storage/src/vespa/storage/distributor/activecopy.cpp index e9d6d8cca30..187c3a138ed 100644 --- a/storage/src/vespa/storage/distributor/activecopy.cpp +++ b/storage/src/vespa/storage/distributor/activecopy.cpp @@ -99,9 +99,8 @@ buildNodeList(const BucketDatabase::Entry& e,vespalib::ConstArrayRef<uint16_t> n SmallActiveCopyList result; result.reserve(nodeIndexes.size()); for (uint16_t nodeIndex : nodeIndexes) { - const BucketCopy *copy = e->getNode(nodeIndex); - assert(copy); - result.emplace_back(nodeIndex, *copy, idealState.lookup(nodeIndex)); + uint16_t entryIndex = e->getRef(nodeIndex); + result.emplace_back(nodeIndex, e->getNodeRef(entryIndex), idealState.lookup(nodeIndex), entryIndex); } return result; } diff --git a/storage/src/vespa/storage/distributor/activecopy.h b/storage/src/vespa/storage/distributor/activecopy.h index 91dfb3f0bd0..e54f4f27ca4 100644 --- a/storage/src/vespa/storage/distributor/activecopy.h +++ b/storage/src/vespa/storage/distributor/activecopy.h @@ -19,13 +19,15 @@ public: : _nodeIndex(Index::invalid()), _ideal(Index::invalid()), _doc_count(0), + _entryIndex(0), _ready(false), _active(false) { } - ActiveCopy(uint16_t node, const BucketCopy & copy, uint16_t ideal) noexcept + ActiveCopy(uint16_t node, const BucketCopy & copy, uint16_t ideal, uint32_t entryIndex_in) noexcept : _nodeIndex(node), _ideal(ideal), _doc_count(copy.getDocumentCount()), + _entryIndex(entryIndex_in), _ready(copy.ready()), _active(copy.active()) { } @@ -36,12 +38,14 @@ public: static ActiveList calculate(const Node2Index & idealState, const lib::Distribution&, const BucketDatabase::Entry&, uint32_t max_activation_inhibited_out_of_sync_groups); uint16_t nodeIndex() const noexcept { return _nodeIndex; } + uint16_t entryIndex() const noexcept { return _entryIndex; } private: friend ActiveStateOrder; bool valid_ideal() const noexcept { return _ideal < Index::invalid(); } uint16_t _nodeIndex; uint16_t _ideal; uint32_t _doc_count; + uint16_t _entryIndex; // Index in BucketCopyList bool _ready; bool _active; }; |