aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib
diff options
context:
space:
mode:
authorhalin-george <halin-george@yandex-team.ru>2022-02-10 16:50:07 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:07 +0300
commit811c91d683d6123a2aa69baa10b30184f5e1204d (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/monlib
parent7c7a0655bcf00449b1fcacc2c658cc4d5c3aca7b (diff)
downloadydb-811c91d683d6123a2aa69baa10b30184f5e1204d.tar.gz
Restoring authorship annotation for <halin-george@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib')
-rw-r--r--library/cpp/monlib/metrics/labels.h232
1 files changed, 116 insertions, 116 deletions
diff --git a/library/cpp/monlib/metrics/labels.h b/library/cpp/monlib/metrics/labels.h
index 285515cb9c..63dc997c28 100644
--- a/library/cpp/monlib/metrics/labels.h
+++ b/library/cpp/monlib/metrics/labels.h
@@ -192,40 +192,40 @@ namespace NMonitoring {
// TLabels
///////////////////////////////////////////////////////////////////////////
template <typename TStringBackend>
- class TLabelsImpl: public ILabels {
+ class TLabelsImpl: public ILabels {
public:
- using value_type = TLabelImpl<TStringBackend>;
-
- TLabelsImpl() = default;
-
- explicit TLabelsImpl(::NDetail::TReserveTag rt)
- : Labels_(std::move(rt))
- {}
-
- explicit TLabelsImpl(size_t count)
- : Labels_(count)
- {}
-
- explicit TLabelsImpl(size_t count, const value_type& label)
- : Labels_(count, label)
- {}
-
- TLabelsImpl(std::initializer_list<value_type> il)
- : Labels_(std::move(il))
- {}
-
- TLabelsImpl(const TLabelsImpl&) = default;
- TLabelsImpl& operator=(const TLabelsImpl&) = default;
-
- TLabelsImpl(TLabelsImpl&&) noexcept = default;
- TLabelsImpl& operator=(TLabelsImpl&&) noexcept = default;
-
+ using value_type = TLabelImpl<TStringBackend>;
+
+ TLabelsImpl() = default;
+
+ explicit TLabelsImpl(::NDetail::TReserveTag rt)
+ : Labels_(std::move(rt))
+ {}
+
+ explicit TLabelsImpl(size_t count)
+ : Labels_(count)
+ {}
+
+ explicit TLabelsImpl(size_t count, const value_type& label)
+ : Labels_(count, label)
+ {}
+
+ TLabelsImpl(std::initializer_list<value_type> il)
+ : Labels_(std::move(il))
+ {}
+
+ TLabelsImpl(const TLabelsImpl&) = default;
+ TLabelsImpl& operator=(const TLabelsImpl&) = default;
+
+ TLabelsImpl(TLabelsImpl&&) noexcept = default;
+ TLabelsImpl& operator=(TLabelsImpl&&) noexcept = default;
+
inline bool operator==(const TLabelsImpl& rhs) const {
- return Labels_ == rhs.Labels_;
+ return Labels_ == rhs.Labels_;
}
inline bool operator!=(const TLabelsImpl& rhs) const {
- return Labels_ != rhs.Labels_;
+ return Labels_ != rhs.Labels_;
}
bool Add(TStringBuf name, TStringBuf value) noexcept override {
@@ -233,43 +233,43 @@ namespace NMonitoring {
return false;
}
- Labels_.emplace_back(name, value);
+ Labels_.emplace_back(name, value);
return true;
}
using ILabels::Add;
bool Has(TStringBuf name) const noexcept override {
- auto it = FindIf(Labels_, [name](const TLabelImpl<TStringBackend>& label) {
+ auto it = FindIf(Labels_, [name](const TLabelImpl<TStringBackend>& label) {
return name == TStringBuf{label.Name()};
});
- return it != Labels_.end();
+ return it != Labels_.end();
}
bool Has(const TString& name) const noexcept {
- auto it = FindIf(Labels_, [name](const TLabelImpl<TStringBackend>& label) {
+ auto it = FindIf(Labels_, [name](const TLabelImpl<TStringBackend>& label) {
return name == TStringBuf{label.Name()};
});
- return it != Labels_.end();
+ return it != Labels_.end();
}
// XXX for backward compatibility
TMaybe<TLabelImpl<TStringBackend>> Find(TStringBuf name) const {
- auto it = FindIf(Labels_, [name](const TLabelImpl<TStringBackend>& label) {
+ auto it = FindIf(Labels_, [name](const TLabelImpl<TStringBackend>& label) {
return name == TStringBuf{label.Name()};
});
- if (it == Labels_.end()) {
+ if (it == Labels_.end()) {
return Nothing();
}
return *it;
}
std::optional<const ILabel*> Get(TStringBuf name) const override {
- auto it = FindIf(Labels_, [name] (auto&& l) {
+ auto it = FindIf(Labels_, [name] (auto&& l) {
return name == l.Name();
});
- if (it == Labels_.end()) {
+ if (it == Labels_.end()) {
return {};
}
@@ -281,116 +281,116 @@ namespace NMonitoring {
}
TMaybe<TLabelImpl<TStringBackend>> Extract(TStringBuf name) {
- auto it = FindIf(Labels_, [name](const TLabelImpl<TStringBackend>& label) {
+ auto it = FindIf(Labels_, [name](const TLabelImpl<TStringBackend>& label) {
return name == TStringBuf{label.Name()};
});
- if (it == Labels_.end()) {
+ if (it == Labels_.end()) {
return Nothing();
}
TLabel tmp = *it;
- Labels_.erase(it);
+ Labels_.erase(it);
return tmp;
}
void SortByName() {
- std::sort(Labels_.begin(), Labels_.end(), [](const auto& lhs, const auto& rhs) {
+ std::sort(Labels_.begin(), Labels_.end(), [](const auto& lhs, const auto& rhs) {
return lhs.Name() < rhs.Name();
});
}
inline size_t Hash() const noexcept override {
- return TSimpleRangeHash()(Labels_);
+ return TSimpleRangeHash()(Labels_);
}
inline TLabel* Data() const noexcept {
- return const_cast<TLabel*>(Labels_.data());
+ return const_cast<TLabel*>(Labels_.data());
}
inline size_t Size() const noexcept override {
- return Labels_.size();
+ return Labels_.size();
}
inline bool Empty() const noexcept override {
- return Labels_.empty();
+ return Labels_.empty();
}
inline void Clear() noexcept override {
- Labels_.clear();
+ Labels_.clear();
};
- TLabelImpl<TStringBackend>& front() {
- return Labels_.front();
- }
-
- const TLabelImpl<TStringBackend>& front() const {
- return Labels_.front();
- }
-
- TLabelImpl<TStringBackend>& back() {
- return Labels_.back();
- }
-
- const TLabelImpl<TStringBackend>& back() const {
- return Labels_.back();
- }
-
- TLabelImpl<TStringBackend>& operator[](size_t index) {
- return Labels_[index];
- }
-
- const TLabelImpl<TStringBackend>& operator[](size_t index) const {
- return Labels_[index];
- }
-
- TLabelImpl<TStringBackend>& at(size_t index) {
- return Labels_.at(index);
- }
-
- const TLabelImpl<TStringBackend>& at(size_t index) const {
- return Labels_.at(index);
- }
-
- size_t capacity() const {
- return Labels_.capacity();
- }
-
- TLabelImpl<TStringBackend>* data() {
- return Labels_.data();
- }
-
- const TLabelImpl<TStringBackend>* data() const {
- return Labels_.data();
- }
-
- size_t size() const {
- return Labels_.size();
- }
-
- bool empty() const {
- return Labels_.empty();
- }
-
- void clear() {
- Labels_.clear();
- }
-
- using ILabels::begin;
- using ILabels::end;
-
- using iterator = ILabels::TIterator;
- using const_iterator = iterator;
-
+ TLabelImpl<TStringBackend>& front() {
+ return Labels_.front();
+ }
+
+ const TLabelImpl<TStringBackend>& front() const {
+ return Labels_.front();
+ }
+
+ TLabelImpl<TStringBackend>& back() {
+ return Labels_.back();
+ }
+
+ const TLabelImpl<TStringBackend>& back() const {
+ return Labels_.back();
+ }
+
+ TLabelImpl<TStringBackend>& operator[](size_t index) {
+ return Labels_[index];
+ }
+
+ const TLabelImpl<TStringBackend>& operator[](size_t index) const {
+ return Labels_[index];
+ }
+
+ TLabelImpl<TStringBackend>& at(size_t index) {
+ return Labels_.at(index);
+ }
+
+ const TLabelImpl<TStringBackend>& at(size_t index) const {
+ return Labels_.at(index);
+ }
+
+ size_t capacity() const {
+ return Labels_.capacity();
+ }
+
+ TLabelImpl<TStringBackend>* data() {
+ return Labels_.data();
+ }
+
+ const TLabelImpl<TStringBackend>* data() const {
+ return Labels_.data();
+ }
+
+ size_t size() const {
+ return Labels_.size();
+ }
+
+ bool empty() const {
+ return Labels_.empty();
+ }
+
+ void clear() {
+ Labels_.clear();
+ }
+
+ using ILabels::begin;
+ using ILabels::end;
+
+ using iterator = ILabels::TIterator;
+ using const_iterator = iterator;
+
protected:
- TVector<TLabelImpl<TStringBackend>>& AsVector() {
- return Labels_;
+ TVector<TLabelImpl<TStringBackend>>& AsVector() {
+ return Labels_;
}
- const TVector<TLabelImpl<TStringBackend>>& AsVector() const {
- return Labels_;
+ const TVector<TLabelImpl<TStringBackend>>& AsVector() const {
+ return Labels_;
}
-
- private:
- TVector<TLabelImpl<TStringBackend>> Labels_;
+
+ private:
+ TVector<TLabelImpl<TStringBackend>> Labels_;
};
using TLabels = TLabelsImpl<TString>;