summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-08-10 13:17:43 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-08-10 16:19:51 +0000
commitdbd97587c91c31992ad4c4c9ac9731dffaebdae4 (patch)
tree3b7350d421ff08dc7e188748feeb66857ae2f589
parent179b2e8d172ab46764d9fb53cbe040fbc2896637 (diff)
Add noexcept
-rw-r--r--storage/src/vespa/storage/bucketdb/bucketinfo.h38
-rw-r--r--storage/src/vespa/storage/bucketdb/bucketinfo.hpp53
-rw-r--r--storage/src/vespa/storage/distributor/activecopy.cpp83
3 files changed, 94 insertions, 80 deletions
diff --git a/storage/src/vespa/storage/bucketdb/bucketinfo.h b/storage/src/vespa/storage/bucketdb/bucketinfo.h
index 57ebf505a50..9a428674dec 100644
--- a/storage/src/vespa/storage/bucketdb/bucketinfo.h
+++ b/storage/src/vespa/storage/bucketdb/bucketinfo.h
@@ -25,15 +25,15 @@ protected:
uint32_t _lastGarbageCollection;
NodeSeq _nodes;
public:
- BucketInfoBase()
+ BucketInfoBase() noexcept
: _lastGarbageCollection(0),
_nodes()
{}
- BucketInfoBase(uint32_t lastGarbageCollection, const NodeSeq& nodes)
+ BucketInfoBase(uint32_t lastGarbageCollection, const NodeSeq& nodes) noexcept
: _lastGarbageCollection(lastGarbageCollection),
_nodes(nodes)
{}
- BucketInfoBase(uint32_t lastGarbageCollection, NodeSeq&& nodes)
+ BucketInfoBase(uint32_t lastGarbageCollection, NodeSeq&& nodes) noexcept
: _lastGarbageCollection(lastGarbageCollection),
_nodes(std::move(nodes))
{}
@@ -47,28 +47,28 @@ public:
/**
* @return Returns the last time when this bucket was "garbage collected".
*/
- uint32_t getLastGarbageCollectionTime() const { return _lastGarbageCollection; }
+ uint32_t getLastGarbageCollectionTime() const noexcept { return _lastGarbageCollection; }
/** True if the bucket contains no documents and is consistent. */
- bool emptyAndConsistent() const;
+ bool emptyAndConsistent() const noexcept;
/**
Check that all copies have complete bucket information and are
consistent with eachother.
*/
- bool validAndConsistent() const;
+ bool validAndConsistent() const noexcept;
/**
* True if the bucket contains at least one invalid copy
*/
- bool hasInvalidCopy() const;
+ bool hasInvalidCopy() const noexcept;
/**
* Returns the number of trusted nodes this entry has.
*/
- uint16_t getTrustedCount() const;
+ uint16_t getTrustedCount() const noexcept;
- bool hasTrusted() const {
+ bool hasTrusted() const noexcept {
return getTrustedCount() != 0;
}
@@ -78,14 +78,14 @@ public:
* @param countInCompleteAsInconsistent If false, nodes that are incomplete
* are always counted as consistent with complete nodes.
*/
- bool consistentNodes(bool countInvalidAsConsistent = false) const;
+ bool consistentNodes(bool countInvalidAsConsistent = false) const noexcept;
void print(std::ostream&, bool verbose, const std::string& indent) const;
/**
* Returns the bucket copy struct for the given node, null if nonexisting
*/
- const BucketCopy* getNode(uint16_t node) const;
+ const BucketCopy* getNode(uint16_t node) const noexcept;
/**
* Returns the number of nodes this entry has.
@@ -95,7 +95,7 @@ public:
/**
* Returns a list of the nodes this entry has.
*/
- std::vector<uint16_t> getNodes() const;
+ std::vector<uint16_t> getNodes() const noexcept;
/**
Returns a reference to the node with the given index in the node
@@ -117,14 +117,14 @@ public:
std::string toString() const;
- uint32_t getHighestDocumentCount() const;
- uint32_t getHighestTotalDocumentSize() const;
- uint32_t getHighestMetaCount() const;
- uint32_t getHighestUsedFileSize() const;
+ uint32_t getHighestDocumentCount() const noexcept;
+ uint32_t getHighestTotalDocumentSize() const noexcept;
+ uint32_t getHighestMetaCount() const noexcept;
+ uint32_t getHighestUsedFileSize() const noexcept;
- bool hasRecentlyCreatedEmptyCopy() const;
+ bool hasRecentlyCreatedEmptyCopy() const noexcept;
- bool operator==(const BucketInfoBase& other) const;
+ bool operator==(const BucketInfoBase& other) const noexcept;
};
template <typename NodeSeq>
@@ -152,7 +152,7 @@ public:
/**
* Sets the last time the bucket was "garbage collected".
*/
- void setLastGarbageCollectionTime(uint32_t timestamp) {
+ void setLastGarbageCollectionTime(uint32_t timestamp) noexcept {
_lastGarbageCollection = timestamp;
}
diff --git a/storage/src/vespa/storage/bucketdb/bucketinfo.hpp b/storage/src/vespa/storage/bucketdb/bucketinfo.hpp
index b7e8c5925c5..c57a293fab1 100644
--- a/storage/src/vespa/storage/bucketdb/bucketinfo.hpp
+++ b/storage/src/vespa/storage/bucketdb/bucketinfo.hpp
@@ -9,14 +9,16 @@
namespace storage {
template <typename NodeSeq>
-std::string BucketInfoBase<NodeSeq>::toString() const {
+std::string
+BucketInfoBase<NodeSeq>::toString() const {
std::ostringstream ost;
print(ost, true, "");
return ost.str();
}
template <typename NodeSeq>
-bool BucketInfoBase<NodeSeq>::emptyAndConsistent() const {
+bool
+BucketInfoBase<NodeSeq>::emptyAndConsistent() const noexcept {
for (uint32_t i = 0; i < _nodes.size(); i++) {
if (!_nodes[i].empty()) {
return false;
@@ -26,7 +28,8 @@ bool BucketInfoBase<NodeSeq>::emptyAndConsistent() const {
}
template <typename NodeSeq>
-bool BucketInfoBase<NodeSeq>::validAndConsistent() const {
+bool
+BucketInfoBase<NodeSeq>::validAndConsistent() const noexcept {
for (uint32_t i = 0; i < _nodes.size(); i++) {
if (!_nodes[i].valid()) {
return false;
@@ -36,7 +39,8 @@ bool BucketInfoBase<NodeSeq>::validAndConsistent() const {
}
template <typename NodeSeq>
-bool BucketInfoBase<NodeSeq>::hasInvalidCopy() const {
+bool
+BucketInfoBase<NodeSeq>::hasInvalidCopy() const noexcept {
for (uint32_t i = 0; i < _nodes.size(); i++) {
if (!_nodes[i].valid()) {
return true;
@@ -46,7 +50,8 @@ bool BucketInfoBase<NodeSeq>::hasInvalidCopy() const {
}
template <typename NodeSeq>
-uint16_t BucketInfoBase<NodeSeq>::getTrustedCount() const {
+uint16_t
+BucketInfoBase<NodeSeq>::getTrustedCount() const noexcept {
uint32_t trustedCount = 0;
for (uint32_t i = 0; i < _nodes.size(); i++) {
if (_nodes[i].trusted()) {
@@ -57,7 +62,8 @@ uint16_t BucketInfoBase<NodeSeq>::getTrustedCount() const {
}
template <typename NodeSeq>
-bool BucketInfoBase<NodeSeq>::consistentNodes(bool countInvalidAsConsistent) const {
+bool
+BucketInfoBase<NodeSeq>::consistentNodes(bool countInvalidAsConsistent) const noexcept {
int compareIndex = 0;
for (uint32_t i = 1; i < _nodes.size(); i++) {
if (!_nodes[i].consistentWith(_nodes[compareIndex],
@@ -90,14 +96,16 @@ struct ReplicaMetadata {
};
};
-constexpr bool is_majority(size_t n, size_t m) {
+constexpr bool
+is_majority(size_t n, size_t m) noexcept {
return (n >= (m / 2) + 1);
}
}
template <typename NodeSeq>
-api::BucketInfo BucketInfoBase<NodeSeq>::majority_consistent_bucket_info() const noexcept {
+api::BucketInfo
+BucketInfoBase<NodeSeq>::majority_consistent_bucket_info() const noexcept {
if (_nodes.size() < 3) {
return {};
}
@@ -116,7 +124,8 @@ api::BucketInfo BucketInfoBase<NodeSeq>::majority_consistent_bucket_info() const
}
template <typename NodeSeq>
-void BucketInfoBase<NodeSeq>::print(std::ostream& out, bool verbose, const std::string& indent) const {
+void
+BucketInfoBase<NodeSeq>::print(std::ostream& out, bool verbose, const std::string& indent) const {
if (_nodes.size() == 0) {
out << "no nodes";
}
@@ -129,7 +138,8 @@ void BucketInfoBase<NodeSeq>::print(std::ostream& out, bool verbose, const std::
}
template <typename NodeSeq>
-const BucketCopy* BucketInfoBase<NodeSeq>::getNode(uint16_t node) const {
+const BucketCopy*
+BucketInfoBase<NodeSeq>::getNode(uint16_t node) const noexcept {
for (const auto& n : _nodes) {
if (n.getNode() == node) {
return &n;
@@ -139,7 +149,8 @@ const BucketCopy* BucketInfoBase<NodeSeq>::getNode(uint16_t node) const {
}
template <typename NodeSeq>
-std::vector<uint16_t> BucketInfoBase<NodeSeq>::getNodes() const {
+std::vector<uint16_t>
+BucketInfoBase<NodeSeq>::getNodes() const noexcept {
std::vector<uint16_t> result;
for (uint32_t i = 0; i < _nodes.size(); i++) {
result.emplace_back(_nodes[i].getNode());
@@ -148,7 +159,8 @@ std::vector<uint16_t> BucketInfoBase<NodeSeq>::getNodes() const {
}
template <typename NodeSeq>
-uint32_t BucketInfoBase<NodeSeq>::getHighestDocumentCount() const {
+uint32_t
+BucketInfoBase<NodeSeq>::getHighestDocumentCount() const noexcept {
uint32_t highest = 0;
for (uint32_t i = 0; i < _nodes.size(); ++i) {
highest = std::max(highest, _nodes[i].getDocumentCount());
@@ -157,7 +169,8 @@ uint32_t BucketInfoBase<NodeSeq>::getHighestDocumentCount() const {
}
template <typename NodeSeq>
-uint32_t BucketInfoBase<NodeSeq>::getHighestTotalDocumentSize() const {
+uint32_t
+BucketInfoBase<NodeSeq>::getHighestTotalDocumentSize() const noexcept {
uint32_t highest = 0;
for (uint32_t i = 0; i < _nodes.size(); ++i) {
highest = std::max(highest, _nodes[i].getTotalDocumentSize());
@@ -166,7 +179,8 @@ uint32_t BucketInfoBase<NodeSeq>::getHighestTotalDocumentSize() const {
}
template <typename NodeSeq>
-uint32_t BucketInfoBase<NodeSeq>::getHighestMetaCount() const {
+uint32_t
+BucketInfoBase<NodeSeq>::getHighestMetaCount() const noexcept {
uint32_t highest = 0;
for (uint32_t i = 0; i < _nodes.size(); ++i) {
highest = std::max(highest, _nodes[i].getMetaCount());
@@ -175,7 +189,8 @@ uint32_t BucketInfoBase<NodeSeq>::getHighestMetaCount() const {
}
template <typename NodeSeq>
-uint32_t BucketInfoBase<NodeSeq>::getHighestUsedFileSize() const {
+uint32_t
+BucketInfoBase<NodeSeq>::getHighestUsedFileSize() const noexcept {
uint32_t highest = 0;
for (uint32_t i = 0; i < _nodes.size(); ++i) {
highest = std::max(highest, _nodes[i].getUsedFileSize());
@@ -184,7 +199,8 @@ uint32_t BucketInfoBase<NodeSeq>::getHighestUsedFileSize() const {
}
template <typename NodeSeq>
-bool BucketInfoBase<NodeSeq>::hasRecentlyCreatedEmptyCopy() const {
+bool
+BucketInfoBase<NodeSeq>::hasRecentlyCreatedEmptyCopy() const noexcept {
for (uint32_t i = 0; i < _nodes.size(); ++i) {
if (_nodes[i].wasRecentlyCreated()) {
return true;
@@ -194,7 +210,8 @@ bool BucketInfoBase<NodeSeq>::hasRecentlyCreatedEmptyCopy() const {
}
template <typename NodeSeq>
-bool BucketInfoBase<NodeSeq>::operator==(const BucketInfoBase<NodeSeq>& other) const {
+bool
+BucketInfoBase<NodeSeq>::operator==(const BucketInfoBase<NodeSeq>& other) const noexcept {
if (_nodes.size() != other._nodes.size()) {
return false;
}
@@ -210,6 +227,6 @@ bool BucketInfoBase<NodeSeq>::operator==(const BucketInfoBase<NodeSeq>& other) c
}
return true;
-};
+}
}
diff --git a/storage/src/vespa/storage/distributor/activecopy.cpp b/storage/src/vespa/storage/distributor/activecopy.cpp
index c46e9868cc8..57052c9c509 100644
--- a/storage/src/vespa/storage/distributor/activecopy.cpp
+++ b/storage/src/vespa/storage/distributor/activecopy.cpp
@@ -91,57 +91,54 @@ operator<<(std::ostream& out, const ActiveCopy & e) {
namespace {
- struct ActiveStateOrder {
- bool operator()(const ActiveCopy & e1, const ActiveCopy & e2) {
- if (e1._ready != e2._ready) {
- return e1._ready;
- }
- if (e1._doc_count != e2._doc_count) {
- return e1._doc_count > e2._doc_count;
- }
- if (e1._ideal != e2._ideal) {
- return e1._ideal < e2._ideal;
- }
- if (e1._active != e2._active) {
- return e1._active;
- }
- return e1._nodeIndex < e2._nodeIndex;
+struct ActiveStateOrder {
+ bool operator()(const ActiveCopy & e1, const ActiveCopy & e2) noexcept {
+ if (e1._ready != e2._ready) {
+ return e1._ready;
}
- };
-
- std::vector<uint16_t>
- buildValidNodeIndexList(BucketDatabase::Entry& e) {
- std::vector<uint16_t> result;
- result.reserve(e->getNodeCount());
- for (uint32_t i=0, n=e->getNodeCount(); i < n; ++i) {
- const BucketCopy& cp = e->getNodeRef(i);
- if (!cp.valid()) {
- continue;
- }
- result.push_back(cp.getNode());
+ if (e1._doc_count != e2._doc_count) {
+ return e1._doc_count > e2._doc_count;
+ }
+ if (e1._ideal != e2._ideal) {
+ return e1._ideal < e2._ideal;
}
- return result;
+ if (e1._active != e2._active) {
+ return e1._active;
+ }
+ return e1._nodeIndex < e2._nodeIndex;
}
-
- std::vector<ActiveCopy>
- buildNodeList(BucketDatabase::Entry& e,
- const std::vector<uint16_t>& nodeIndexes,
- const std::vector<uint16_t>& idealState)
- {
- std::vector<ActiveCopy> result;
- result.reserve(nodeIndexes.size());
- for (uint16_t nodeIndex : nodeIndexes) {
- result.emplace_back(nodeIndex, e, idealState);
+};
+
+std::vector<uint16_t>
+buildValidNodeIndexList(BucketDatabase::Entry& e) {
+ std::vector<uint16_t> result;
+ result.reserve(e->getNodeCount());
+ for (uint32_t i=0, n=e->getNodeCount(); i < n; ++i) {
+ const BucketCopy& cp = e->getNodeRef(i);
+ if (!cp.valid()) {
+ continue;
}
- return result;
+ result.push_back(cp.getNode());
}
+ return result;
+}
+
+std::vector<ActiveCopy>
+buildNodeList(BucketDatabase::Entry& e, const std::vector<uint16_t>& nodeIndexes, const std::vector<uint16_t>& idealState)
+{
+ std::vector<ActiveCopy> result;
+ result.reserve(nodeIndexes.size());
+ for (uint16_t nodeIndex : nodeIndexes) {
+ result.emplace_back(nodeIndex, e, idealState);
+ }
+ return result;
+}
+
}
ActiveList
-ActiveCopy::calculate(const std::vector<uint16_t>& idealState,
- const lib::Distribution& distribution,
- BucketDatabase::Entry& e,
- uint32_t max_activation_inhibited_out_of_sync_groups)
+ActiveCopy::calculate(const std::vector<uint16_t>& idealState, const lib::Distribution& distribution,
+ BucketDatabase::Entry& e, uint32_t max_activation_inhibited_out_of_sync_groups)
{
std::vector<uint16_t> validNodesWithCopy = buildValidNodeIndexList(e);
if (validNodesWithCopy.empty()) {