From 87253fbc538f8935d9483e0a5b8aac4201cecd7a Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 4 Sep 2023 20:25:33 +0000 Subject: Find index and store it in ActiveCopy. --- storage/src/vespa/storage/bucketdb/bucketinfo.h | 1 + storage/src/vespa/storage/bucketdb/bucketinfo.hpp | 13 ++++++++++++- storage/src/vespa/storage/distributor/activecopy.cpp | 5 ++--- storage/src/vespa/storage/distributor/activecopy.h | 6 +++++- 4 files changed, 20 insertions(+), 5 deletions(-) (limited to 'storage') 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::getNode(uint16_t node) const noexcept { return &n; } } + return nullptr; +} + +template +uint16_t +BucketInfoBase::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::operator==(const BucketInfoBase& 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 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; }; -- cgit v1.2.3