diff options
| author | prime <[email protected]> | 2022-02-10 16:46:01 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:46:01 +0300 | 
| commit | e34f3f0e381020a427f44fbd50463d9a04089db3 (patch) | |
| tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/monlib/encode | |
| parent | 3695a7cd42b74a4987d8d5a8f2e2443556998943 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/encode')
9 files changed, 73 insertions, 73 deletions
| diff --git a/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp b/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp index 3f18e42d6ef..87c832d642b 100644 --- a/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp +++ b/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp @@ -89,25 +89,25 @@ void TBufferedEncoderBase::OnLabel(TStringBuf name, TStringBuf value) {      labels->emplace_back(LabelNamesPool_.PutIfAbsent(name), LabelValuesPool_.PutIfAbsent(value));  } -void TBufferedEncoderBase::OnLabel(ui32 name, ui32 value) {  -    TPooledLabels* labels;  -    if (State_ == TEncoderState::EState::METRIC_LABELS) {  -        labels = &Metrics_.back().Labels;  -    } else if (State_ == TEncoderState::EState::COMMON_LABELS) {  -        labels = &CommonLabels_;  -    } else {  -        State_.ThrowInvalid("expected LABELS or COMMON_LABELS");  -    }  -  -    labels->emplace_back(LabelNamesPool_.GetByIndex(name), LabelValuesPool_.GetByIndex(value));  -}  -  +void TBufferedEncoderBase::OnLabel(ui32 name, ui32 value) { +    TPooledLabels* labels; +    if (State_ == TEncoderState::EState::METRIC_LABELS) { +        labels = &Metrics_.back().Labels; +    } else if (State_ == TEncoderState::EState::COMMON_LABELS) { +        labels = &CommonLabels_; +    } else { +        State_.ThrowInvalid("expected LABELS or COMMON_LABELS"); +    } + +    labels->emplace_back(LabelNamesPool_.GetByIndex(name), LabelValuesPool_.GetByIndex(value)); +} +  std::pair<ui32, ui32> TBufferedEncoderBase::PrepareLabel(TStringBuf name, TStringBuf value) { -    auto nameLabel = LabelNamesPool_.PutIfAbsent(name);  -    auto valueLabel = LabelValuesPool_.PutIfAbsent(value);  -    return std::make_pair(nameLabel->Index, valueLabel->Index);  -}  -  +    auto nameLabel = LabelNamesPool_.PutIfAbsent(name); +    auto valueLabel = LabelValuesPool_.PutIfAbsent(value); +    return std::make_pair(nameLabel->Index, valueLabel->Index); +} +  void TBufferedEncoderBase::OnDouble(TInstant time, double value) {      State_.Expect(TEncoderState::EState::METRIC);      TMetric& metric = Metrics_.back(); diff --git a/library/cpp/monlib/encode/buffered/buffered_encoder_base.h b/library/cpp/monlib/encode/buffered/buffered_encoder_base.h index 165d92203ef..fe3714e58f0 100644 --- a/library/cpp/monlib/encode/buffered/buffered_encoder_base.h +++ b/library/cpp/monlib/encode/buffered/buffered_encoder_base.h @@ -26,7 +26,7 @@ public:      void OnLabelsBegin() override;      void OnLabelsEnd() override;      void OnLabel(TStringBuf name, TStringBuf value) override; -    void OnLabel(ui32 name, ui32 value) override;  +    void OnLabel(ui32 name, ui32 value) override;      std::pair<ui32, ui32> PrepareLabel(TStringBuf name, TStringBuf value) override;      void OnDouble(TInstant time, double value) override; diff --git a/library/cpp/monlib/encode/buffered/string_pool.cpp b/library/cpp/monlib/encode/buffered/string_pool.cpp index d819e11ae72..b4c7988ba33 100644 --- a/library/cpp/monlib/encode/buffered/string_pool.cpp +++ b/library/cpp/monlib/encode/buffered/string_pool.cpp @@ -10,8 +10,8 @@ namespace NMonitoring {          auto [it, isInserted] = StrMap_.try_emplace(str, Max<ui32>(), 0);          if (isInserted) {              BytesSize_ += str.size(); -            it->second.Index = StrVector_.size();  -            StrVector_.emplace_back(it->first, &it->second);  +            it->second.Index = StrVector_.size(); +            StrVector_.emplace_back(it->first, &it->second);          }          TValue* value = &it->second; @@ -19,10 +19,10 @@ namespace NMonitoring {          return value;      } -    const TStringPoolBuilder::TValue* TStringPoolBuilder::GetByIndex(ui32 index) const {  -        return StrVector_.at(index).second;  -    }  -  +    const TStringPoolBuilder::TValue* TStringPoolBuilder::GetByIndex(ui32 index) const { +        return StrVector_.at(index).second; +    } +      TStringPoolBuilder& TStringPoolBuilder::Build() {          if (RequiresSorting_) {              // sort in reversed order @@ -30,10 +30,10 @@ namespace NMonitoring {                  return a.second->Frequency > b.second->Frequency;              }); -            ui32 i = 0;  -            for (auto& value : StrVector_) {  -                value.second->Index = i++;  -            }  +            ui32 i = 0; +            for (auto& value : StrVector_) { +                value.second->Index = i++; +            }          }          IsBuilt_ = true; diff --git a/library/cpp/monlib/encode/buffered/string_pool.h b/library/cpp/monlib/encode/buffered/string_pool.h index e216cff3886..00e5644608a 100644 --- a/library/cpp/monlib/encode/buffered/string_pool.h +++ b/library/cpp/monlib/encode/buffered/string_pool.h @@ -22,7 +22,7 @@ namespace NMonitoring {      public:          const TValue* PutIfAbsent(TStringBuf str); -        const TValue* GetByIndex(ui32 index) const;  +        const TValue* GetByIndex(ui32 index) const;          /// Determines whether pool must be sorted by value frequencies          TStringPoolBuilder& SetSorted(bool sorted) { diff --git a/library/cpp/monlib/encode/buffered/string_pool_ut.cpp b/library/cpp/monlib/encode/buffered/string_pool_ut.cpp index 21839ccb470..9fc3421d0bb 100644 --- a/library/cpp/monlib/encode/buffered/string_pool_ut.cpp +++ b/library/cpp/monlib/encode/buffered/string_pool_ut.cpp @@ -16,10 +16,10 @@ Y_UNIT_TEST_SUITE(TStringPoolTest) {          UNIT_ASSERT(h2 == h3);          UNIT_ASSERT_VALUES_EQUAL(h1->Frequency, 1); -        UNIT_ASSERT_VALUES_EQUAL(h1->Index, 0);  +        UNIT_ASSERT_VALUES_EQUAL(h1->Index, 0);          UNIT_ASSERT_VALUES_EQUAL(h2->Frequency, 2); -        UNIT_ASSERT_VALUES_EQUAL(h2->Index, 1);  +        UNIT_ASSERT_VALUES_EQUAL(h2->Index, 1);          UNIT_ASSERT_VALUES_EQUAL(strPool.BytesSize(), 6);          UNIT_ASSERT_VALUES_EQUAL(strPool.Count(), 2); @@ -49,8 +49,8 @@ Y_UNIT_TEST_SUITE(TStringPoolTest) {      Y_UNIT_TEST(ForEach) {          TStringPoolBuilder strPool; -        strPool.SetSorted(true);  -  +        strPool.SetSorted(true); +          strPool.PutIfAbsent("one");          strPool.PutIfAbsent("two");          strPool.PutIfAbsent("two"); diff --git a/library/cpp/monlib/encode/json/json_encoder.cpp b/library/cpp/monlib/encode/json/json_encoder.cpp index e376cbb5645..20d2bb6283f 100644 --- a/library/cpp/monlib/encode/json/json_encoder.cpp +++ b/library/cpp/monlib/encode/json/json_encoder.cpp @@ -440,11 +440,11 @@ namespace NMonitoring {                  EmptyLabels_ = false;              } -            void OnLabel(ui32 name, ui32 value) override {  -                TBufferedEncoderBase::OnLabel(name, value);  -                EmptyLabels_ = false;  -            }  -  +            void OnLabel(ui32 name, ui32 value) override { +                TBufferedEncoderBase::OnLabel(name, value); +                EmptyLabels_ = false; +            } +              void OnLabelsEnd() override {                  TBufferedEncoderBase::OnLabelsEnd();                  Y_ENSURE(!EmptyLabels_, "Labels cannot be empty"); diff --git a/library/cpp/monlib/encode/json/json_ut.cpp b/library/cpp/monlib/encode/json/json_ut.cpp index 281c114a235..09e79092890 100644 --- a/library/cpp/monlib/encode/json/json_ut.cpp +++ b/library/cpp/monlib/encode/json/json_ut.cpp @@ -225,14 +225,14 @@ Y_UNIT_TEST_SUITE(TJsonTest) {              e->Close();              json += "\n"; -            auto parseJson = [] (auto buf) {  -                NJson::TJsonValue value;  -                NJson::ReadJsonTree(buf, &value, true);  -                return value;  -            };  -  +            auto parseJson = [] (auto buf) { +                NJson::TJsonValue value; +                NJson::ReadJsonTree(buf, &value, true); +                return value; +            }; +              const auto expectedJson = NResource::Find(expectedResourceKey); -            UNIT_ASSERT_EQUAL(parseJson(json), parseJson(expectedJson));  +            UNIT_ASSERT_EQUAL(parseJson(json), parseJson(expectedJson));          };          check(false, false, "/expected.json"); diff --git a/library/cpp/monlib/encode/json/ut/expected_buffered.json b/library/cpp/monlib/encode/json/ut/expected_buffered.json index 0441766a68e..9a6a1d6201d 100644 --- a/library/cpp/monlib/encode/json/ut/expected_buffered.json +++ b/library/cpp/monlib/encode/json/ut/expected_buffered.json @@ -10,8 +10,8 @@          "kind":"COUNTER",          "labels":            { -            "labels":"l1",  -            "metric":"single"  +            "labels":"l1", +            "metric":"single"            },          "ts":1509843723,          "value":17 @@ -20,8 +20,8 @@          "kind":"RATE",          "labels":            { -            "labels":"l2",  -            "metric":"single"  +            "labels":"l2", +            "metric":"single"            },          "ts":1509843723,          "value":17 @@ -30,8 +30,8 @@          "kind":"GAUGE",          "labels":            { -            "labels":"l3",  -            "metric":"single"  +            "labels":"l3", +            "metric":"single"            },          "ts":1509843723,          "value":3.14 @@ -40,8 +40,8 @@          "kind":"IGAUGE",          "labels":            { -            "labels":"l4",  -            "metric":"single_igauge"  +            "labels":"l4", +            "metric":"single_igauge"            },          "ts":1509843723,          "value":42 @@ -50,8 +50,8 @@          "kind":"GAUGE",          "labels":            { -            "labels":"l5",  -            "metric":"multiple"  +            "labels":"l5", +            "metric":"multiple"            },          "timeseries":            [ @@ -73,8 +73,8 @@          "kind":"COUNTER",          "labels":            { -            "labels":"l6",  -            "metric":"multiple"  +            "labels":"l6", +            "metric":"multiple"            },          "timeseries":            [ diff --git a/library/cpp/monlib/encode/spack/spack_v1_ut.cpp b/library/cpp/monlib/encode/spack/spack_v1_ut.cpp index 7802f7c5e9c..fe778eb7e02 100644 --- a/library/cpp/monlib/encode/spack/spack_v1_ut.cpp +++ b/library/cpp/monlib/encode/spack/spack_v1_ut.cpp @@ -78,18 +78,18 @@ Y_UNIT_TEST_SUITE(TSpackTest) {      ui8 expectedStringPools[] = {          0x6e, 0x61, 0x6d, 0x65, 0x00,                   // "name\0"          0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x00, // "project\0" -        0x73, 0x6f, 0x6c, 0x6f, 0x6d, 0x6f, 0x6e, 0x00, // "solomon\0"  -        0x71, 0x31, 0x00,                               // "q1\0"  -        0x71, 0x32, 0x00,                               // "q2\0"  -        0x71, 0x33, 0x00,                               // "q3\0"  -        0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x00,       // "answer\0"  +        0x73, 0x6f, 0x6c, 0x6f, 0x6d, 0x6f, 0x6e, 0x00, // "solomon\0" +        0x71, 0x31, 0x00,                               // "q1\0" +        0x71, 0x32, 0x00,                               // "q2\0" +        0x71, 0x33, 0x00,                               // "q3\0" +        0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x00,       // "answer\0"          0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, // "responseTimeMillis\0"          0x54, 0x69, 0x6d, 0x65, 0x4d, 0x69, 0x6c, 0x6c,          0x69, 0x73, 0x00,          0x62, 0x79, 0x74, 0x65, 0x73, 0x00,             // "bytes\0" -        0x74, 0x65, 0x6D, 0x70, 0x65, 0x72, 0x61, 0x74, // "temperature\0"  -        0x75, 0x72, 0x65, 0x00,  -        0x6d, 0x73, 0x00,                               // "ms\0"  +        0x74, 0x65, 0x6D, 0x70, 0x65, 0x72, 0x61, 0x74, // "temperature\0" +        0x75, 0x72, 0x65, 0x00, +        0x6d, 0x73, 0x00,                               // "ms\0"      };      ui8 expectedCommonTime[] = { @@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {      ui8 expectedCommonLabels[] = {          0x01, // common labels count                     (varint)          0x01, // label name index                        (varint) -        0x00, // label value index                       (varint)  +        0x00, // label value index                       (varint)      };      ui8 expectedMetric1[] = { @@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {          0x00, // flags                                   (fixed ui8)          0x01, // metric labels count                     (varint)          0x00, // label name index                        (varint) -        0x01, // label value index                       (varint)  +        0x01, // label value index                       (varint)      };      ui8 expectedMetric2[] = { @@ -115,7 +115,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {          0x00,                                           // flags                                   (fixed ui8)          0x01,                                           // metric labels count                     (varint)          0x00,                                           // label name index                        (varint) -        0x02,                                           // label value index                       (varint)  +        0x02,                                           // label value index                       (varint)          0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // value (fixed ui64)      }; @@ -147,7 +147,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {          0x00,                                           // flags                                   (fixed ui8)          0x01,                                           // metric labels count                     (varint)          0x00,                                           // label name index                        (varint) -        0x05,                                           // label value index                       (varint)  +        0x05,                                           // label value index                       (varint)          0x0b, 0x63, 0xfe, 0x59,                         // time in seconds                         (fixed ui32)          0x06,                                           // histogram buckets count                 (varint)          0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // histogram bucket bounds                 (array of fixed ui64) @@ -169,7 +169,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {          0x00,                                           // flags                                   (fixed ui8)          0x01,                                           // metric labels count                     (varint)          0x00,                                           // label name index                        (varint) -        0x05,                                           // label value index                       (varint)  +        0x05,                                           // label value index                       (varint)          0x0b, 0x63, 0xfe, 0x59,                         // time in seconds                         (fixed ui32)          0x06,                                           // histogram buckets count                 (varint)          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, // histogram bucket bounds                 (array of doubles) @@ -201,7 +201,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {          0x00,                                           // flags                                   (fixed ui8)          0x01,                                           // metric labels count                     (varint)          0x00,                                           // label name index                        (varint) -        0x07,                                           // label value index                       (varint)  +        0x07,                                           // label value index                       (varint)          0x0b, 0x63, 0xfe, 0x59,                         // time in seconds                         (fixed ui32)          0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // count                                   (fixed ui64)          0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x24, 0x40, // sum                                     (fixed double) @@ -755,7 +755,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {                      e->OnMetricBegin(EMetricType::COUNTER);                      {                          e->OnLabelsBegin(); -                        e->OnLabel("project", "solomon");  +                        e->OnLabel("project", "solomon");                          e->OnLabel("s", "temperature");                          e->OnLabelsEnd();                      } | 
