diff options
author | victor-k <victor-k@yandex-team.ru> | 2022-02-10 16:50:38 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:38 +0300 |
commit | f632afcab870d2327aaa8388ceeb7aeb2bb6a1c1 (patch) | |
tree | 7bf4ee5af2c901bfd7715a527d63fad8eabf861d | |
parent | fdec3824b69496e472972311be8d8157a8bb99db (diff) | |
download | ydb-f632afcab870d2327aaa8388ceeb7aeb2bb6a1c1.tar.gz |
Restoring authorship annotation for <victor-k@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_builder.h | 14 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_builder.inl | 46 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_ut.cpp | 100 | ||||
-rw-r--r-- | library/cpp/histogram/adaptive/adaptive_histogram.cpp | 50 | ||||
-rw-r--r-- | library/cpp/histogram/adaptive/adaptive_histogram.h | 14 | ||||
-rw-r--r-- | library/cpp/histogram/adaptive/auto_histogram.h | 28 | ||||
-rw-r--r-- | library/cpp/histogram/adaptive/block_histogram.cpp | 40 | ||||
-rw-r--r-- | library/cpp/histogram/adaptive/block_histogram.h | 16 | ||||
-rw-r--r-- | library/cpp/histogram/adaptive/fixed_bin_histogram.cpp | 60 | ||||
-rw-r--r-- | library/cpp/histogram/adaptive/fixed_bin_histogram.h | 16 | ||||
-rw-r--r-- | library/cpp/histogram/adaptive/histogram.h | 10 | ||||
-rw-r--r-- | library/cpp/histogram/adaptive/multi_histogram.h | 4 | ||||
-rw-r--r-- | library/cpp/monlib/deprecated/json/writer.cpp | 6 | ||||
-rw-r--r-- | library/cpp/monlib/deprecated/json/writer.h | 16 | ||||
-rw-r--r-- | library/cpp/monlib/dynamic_counters/page.h | 8 |
15 files changed, 214 insertions, 214 deletions
diff --git a/library/cpp/containers/comptrie/comptrie_builder.h b/library/cpp/containers/comptrie/comptrie_builder.h index cf7d2e39a3..3a03ea08c4 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.h +++ b/library/cpp/containers/comptrie/comptrie_builder.h @@ -34,9 +34,9 @@ inline TCompactTrieBuilderFlags& operator|=(TCompactTrieBuilderFlags& first, TCo return first = first | second; } -template <typename T> -class TArrayWithSizeHolder; - +template <typename T> +class TArrayWithSizeHolder; + template <class T = char, class D = ui64, class S = TCompactTriePacker<D>> class TCompactTrieBuilder { public: @@ -66,11 +66,11 @@ public: return AddSubtreeInFile(key.data(), key.size(), filename); } - bool AddSubtreeInBuffer(const TSymbol* key, size_t keylen, TArrayWithSizeHolder<char>&& buffer); - bool AddSubtreeInBuffer(const TKeyBuf& key, TArrayWithSizeHolder<char>&& buffer) { + bool AddSubtreeInBuffer(const TSymbol* key, size_t keylen, TArrayWithSizeHolder<char>&& buffer); + bool AddSubtreeInBuffer(const TKeyBuf& key, TArrayWithSizeHolder<char>&& buffer) { return AddSubtreeInBuffer(key.data(), key.size(), std::move(buffer)); - } - + } + bool Find(const TSymbol* key, size_t keylen, TData* value) const; bool Find(const TKeyBuf& key, TData* value = nullptr) const { return Find(key.data(), key.size(), value); diff --git a/library/cpp/containers/comptrie/comptrie_builder.inl b/library/cpp/containers/comptrie/comptrie_builder.inl index f273fa6571..dd3bf83025 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.inl +++ b/library/cpp/containers/comptrie/comptrie_builder.inl @@ -79,7 +79,7 @@ public: bool AddEntry(const TSymbol* key, size_t keylen, const TData& value); bool AddEntryPtr(const TSymbol* key, size_t keylen, const char* value); bool AddSubtreeInFile(const TSymbol* key, size_t keylen, const TString& fileName); - bool AddSubtreeInBuffer(const TSymbol* key, size_t keylen, TArrayWithSizeHolder<char>&& buffer); + bool AddSubtreeInBuffer(const TSymbol* key, size_t keylen, TArrayWithSizeHolder<char>&& buffer); bool FindEntry(const TSymbol* key, size_t keylen, TData* value) const; bool FindLongestPrefix(const TSymbol* key, size_t keylen, size_t* prefixlen, TData* value) const; @@ -441,11 +441,11 @@ bool TCompactTrieBuilder<T, D, S>::AddSubtreeInFile(const TSymbol* key, size_t k } template <class T, class D, class S> -bool TCompactTrieBuilder<T, D, S>::AddSubtreeInBuffer(const TSymbol* key, size_t keylen, TArrayWithSizeHolder<char>&& buffer) { - return Impl->AddSubtreeInBuffer(key, keylen, std::move(buffer)); -} - -template <class T, class D, class S> +bool TCompactTrieBuilder<T, D, S>::AddSubtreeInBuffer(const TSymbol* key, size_t keylen, TArrayWithSizeHolder<char>&& buffer) { + return Impl->AddSubtreeInBuffer(key, keylen, std::move(buffer)); +} + +template <class T, class D, class S> bool TCompactTrieBuilder<T, D, S>::Find(const TSymbol* key, size_t keylen, TData* value) const { return Impl->FindEntry(key, keylen, value); } @@ -580,23 +580,23 @@ bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::AddSubtreeInFile( } template <class T, class D, class S> -bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::AddSubtreeInBuffer( - const TSymbol* key, size_t keylen, TArrayWithSizeHolder<char>&& buffer) { - - typedef typename TNode::TBufferedSubtree TBufferedSubtree; - - bool isNewAddition = false; - TNode* node = AddEntryForSomething(key, keylen, isNewAddition); - node->Subtree()->Destroy(this); - node->Subtree()->~ISubtree(); - - auto subtree = new (node->Subtree()) TBufferedSubtree(); - subtree->Buffer.Swap(buffer); - - return isNewAddition; -} - -template <class T, class D, class S> +bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::AddSubtreeInBuffer( + const TSymbol* key, size_t keylen, TArrayWithSizeHolder<char>&& buffer) { + + typedef typename TNode::TBufferedSubtree TBufferedSubtree; + + bool isNewAddition = false; + TNode* node = AddEntryForSomething(key, keylen, isNewAddition); + node->Subtree()->Destroy(this); + node->Subtree()->~ISubtree(); + + auto subtree = new (node->Subtree()) TBufferedSubtree(); + subtree->Buffer.Swap(buffer); + + return isNewAddition; +} + +template <class T, class D, class S> typename TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::TNode* TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::AddEntryForSomething( const TSymbol* key, size_t keylen, bool& isNewAddition) { diff --git a/library/cpp/containers/comptrie/comptrie_ut.cpp b/library/cpp/containers/comptrie/comptrie_ut.cpp index 74bee09b5d..f159d91f5e 100644 --- a/library/cpp/containers/comptrie/comptrie_ut.cpp +++ b/library/cpp/containers/comptrie/comptrie_ut.cpp @@ -65,8 +65,8 @@ private: UNIT_TEST(TestFindTails); UNIT_TEST(TestPrefixGrouped); UNIT_TEST(CrashTestPrefixGrouped); - UNIT_TEST(TestMergeFromFile); - UNIT_TEST(TestMergeFromBuffer); + UNIT_TEST(TestMergeFromFile); + UNIT_TEST(TestMergeFromBuffer); UNIT_TEST(TestUnique); UNIT_TEST(TestAddRetValue); UNIT_TEST(TestClear); @@ -202,8 +202,8 @@ public: void TestFindTails(); void TestPrefixGrouped(); void CrashTestPrefixGrouped(); - void TestMergeFromFile(); - void TestMergeFromBuffer(); + void TestMergeFromFile(); + void TestMergeFromBuffer(); void TestUnique(); void TestAddRetValue(); void TestClear(); @@ -841,7 +841,7 @@ void TCompactTrieTest::CrashTestPrefixGrouped() { UNIT_ASSERT_C(wasException, "CrashTestPrefixGrouped"); } -void TCompactTrieTest::TestMergeFromFile() { +void TCompactTrieTest::TestMergeFromFile() { { TCompactTrieBuilder<> b; b.Add("yandex", 12); @@ -883,52 +883,52 @@ void TCompactTrieTest::TestMergeFromFile() { unlink((GetSystemTempDir() + "/TCompactTrieTest-TestMerge-ru").data()); } -void TCompactTrieTest::TestMergeFromBuffer() { - TArrayWithSizeHolder<char> buffer1; - { - TCompactTrieBuilder<> b; - b.Add("aaaaa", 1); - b.Add("bbbbb", 2); - b.Add("ccccc", 3); - buffer1.Resize(b.MeasureByteSize()); - TMemoryOutput out(buffer1.Get(), buffer1.Size()); - b.Save(out); - } - - TArrayWithSizeHolder<char> buffer2; - { - TCompactTrieBuilder<> b; - b.Add("aaaaa", 10); - b.Add("bbbbb", 20); - b.Add("ccccc", 30); - b.Add("xxxxx", 40); - b.Add("yyyyy", 50); - buffer2.Resize(b.MeasureByteSize()); - TMemoryOutput out(buffer2.Get(), buffer2.Size()); - b.Save(out); - } - - { - TCompactTrieBuilder<> b; - UNIT_ASSERT(b.AddSubtreeInBuffer("com.", std::move(buffer1))); - UNIT_ASSERT(b.Add("org.upyachka", 42)); - UNIT_ASSERT(b.AddSubtreeInBuffer("ru.", std::move(buffer2))); - TUnbufferedFileOutput out(GetSystemTempDir() + "/TCompactTrieTest-TestMergeFromBuffer-res"); - b.Save(out); - } - - TCompactTrie<> trie(TBlob::FromFileSingleThreaded(GetSystemTempDir() + "/TCompactTrieTest-TestMergeFromBuffer-res")); - UNIT_ASSERT_VALUES_EQUAL(10u, trie.Get("ru.aaaaa")); - UNIT_ASSERT_VALUES_EQUAL(20u, trie.Get("ru.bbbbb")); - UNIT_ASSERT_VALUES_EQUAL(40u, trie.Get("ru.xxxxx")); - UNIT_ASSERT_VALUES_EQUAL(42u, trie.Get("org.upyachka")); - UNIT_ASSERT_VALUES_EQUAL(1u, trie.Get("com.aaaaa")); - UNIT_ASSERT_VALUES_EQUAL(2u, trie.Get("com.bbbbb")); - UNIT_ASSERT_VALUES_EQUAL(3u, trie.Get("com.ccccc")); - +void TCompactTrieTest::TestMergeFromBuffer() { + TArrayWithSizeHolder<char> buffer1; + { + TCompactTrieBuilder<> b; + b.Add("aaaaa", 1); + b.Add("bbbbb", 2); + b.Add("ccccc", 3); + buffer1.Resize(b.MeasureByteSize()); + TMemoryOutput out(buffer1.Get(), buffer1.Size()); + b.Save(out); + } + + TArrayWithSizeHolder<char> buffer2; + { + TCompactTrieBuilder<> b; + b.Add("aaaaa", 10); + b.Add("bbbbb", 20); + b.Add("ccccc", 30); + b.Add("xxxxx", 40); + b.Add("yyyyy", 50); + buffer2.Resize(b.MeasureByteSize()); + TMemoryOutput out(buffer2.Get(), buffer2.Size()); + b.Save(out); + } + + { + TCompactTrieBuilder<> b; + UNIT_ASSERT(b.AddSubtreeInBuffer("com.", std::move(buffer1))); + UNIT_ASSERT(b.Add("org.upyachka", 42)); + UNIT_ASSERT(b.AddSubtreeInBuffer("ru.", std::move(buffer2))); + TUnbufferedFileOutput out(GetSystemTempDir() + "/TCompactTrieTest-TestMergeFromBuffer-res"); + b.Save(out); + } + + TCompactTrie<> trie(TBlob::FromFileSingleThreaded(GetSystemTempDir() + "/TCompactTrieTest-TestMergeFromBuffer-res")); + UNIT_ASSERT_VALUES_EQUAL(10u, trie.Get("ru.aaaaa")); + UNIT_ASSERT_VALUES_EQUAL(20u, trie.Get("ru.bbbbb")); + UNIT_ASSERT_VALUES_EQUAL(40u, trie.Get("ru.xxxxx")); + UNIT_ASSERT_VALUES_EQUAL(42u, trie.Get("org.upyachka")); + UNIT_ASSERT_VALUES_EQUAL(1u, trie.Get("com.aaaaa")); + UNIT_ASSERT_VALUES_EQUAL(2u, trie.Get("com.bbbbb")); + UNIT_ASSERT_VALUES_EQUAL(3u, trie.Get("com.ccccc")); + unlink((GetSystemTempDir() + "/TCompactTrieTest-TestMergeFromBuffer-res").data()); -} - +} + void TCompactTrieTest::TestUnique() { TestUniqueImpl(false); TestUniqueImpl(true); diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.cpp b/library/cpp/histogram/adaptive/adaptive_histogram.cpp index cbfc494021..b1e7e85aed 100644 --- a/library/cpp/histogram/adaptive/adaptive_histogram.cpp +++ b/library/cpp/histogram/adaptive/adaptive_histogram.cpp @@ -8,7 +8,7 @@ #include <util/system/backtrace.h> namespace NKiwiAggr { - TAdaptiveHistogram::TAdaptiveHistogram(size_t intervals, ui64 id, TQualityFunction qualityFunc) + TAdaptiveHistogram::TAdaptiveHistogram(size_t intervals, ui64 id, TQualityFunction qualityFunc) : Id(id) , Sum(0.0) , Intervals(intervals) @@ -16,13 +16,13 @@ namespace NKiwiAggr { { } - TAdaptiveHistogram::TAdaptiveHistogram(const THistogram& histo, size_t defaultIntervals, ui64 defaultId, TQualityFunction qualityFunc) + TAdaptiveHistogram::TAdaptiveHistogram(const THistogram& histo, size_t defaultIntervals, ui64 defaultId, TQualityFunction qualityFunc) : TAdaptiveHistogram(defaultIntervals, defaultId, qualityFunc) { FromProto(histo); } - TAdaptiveHistogram::TAdaptiveHistogram(IHistogram* histo, size_t defaultIntervals, ui64 defaultId, TQualityFunction qualityFunc) + TAdaptiveHistogram::TAdaptiveHistogram(IHistogram* histo, size_t defaultIntervals, ui64 defaultId, TQualityFunction qualityFunc) : TAdaptiveHistogram(defaultIntervals, defaultId, qualityFunc) { TAdaptiveHistogram* adaptiveHisto = dynamic_cast<TAdaptiveHistogram*>(histo); @@ -60,7 +60,7 @@ namespace NKiwiAggr { void TAdaptiveHistogram::Add(double value, double weight) { if (!IsValidFloat(value) || !IsValidFloat(weight)) { - ythrow yexception() << Sprintf("Histogram id %lu: bad value %f weight %f", Id, value, weight); + ythrow yexception() << Sprintf("Histogram id %lu: bad value %f weight %f", Id, value, weight); } TWeightedValue weightedValue(value, weight); Add(weightedValue, true); @@ -69,7 +69,7 @@ namespace NKiwiAggr { void TAdaptiveHistogram::Merge(const THistogram& histo, double multiplier) { if (!IsValidFloat(histo.GetMinValue()) || !IsValidFloat(histo.GetMaxValue())) { - fprintf(stderr, "Merging in histogram id %lu: skip bad histo with minvalue %f maxvalue %f\n", Id, histo.GetMinValue(), histo.GetMaxValue()); + fprintf(stderr, "Merging in histogram id %lu: skip bad histo with minvalue %f maxvalue %f\n", Id, histo.GetMinValue(), histo.GetMaxValue()); return; } if (histo.FreqSize() == 0) { @@ -85,7 +85,7 @@ namespace NKiwiAggr { double value = histo.GetPosition(j); double weight = histo.GetFreq(j); if (!IsValidFloat(value) || !IsValidFloat(weight)) { - fprintf(stderr, "Merging in histogram id %lu: skip bad value %f weight %f\n", Id, value, weight); + fprintf(stderr, "Merging in histogram id %lu: skip bad value %f weight %f\n", Id, value, weight); continue; } Add(value, weight * multiplier); @@ -98,7 +98,7 @@ namespace NKiwiAggr { for (size_t j = 0; j < histo.FreqSize(); ++j) { double weight = histo.GetFreq(j); if (!IsValidFloat(pos) || !IsValidFloat(weight)) { - fprintf(stderr, "Merging in histogram id %lu: skip bad value %f weight %f\n", Id, pos, weight); + fprintf(stderr, "Merging in histogram id %lu: skip bad value %f weight %f\n", Id, pos, weight); pos += histo.GetBinRange(); continue; } @@ -216,14 +216,14 @@ namespace NKiwiAggr { double value = histo.GetPosition(i); double weight = histo.GetFreq(i); if (!IsValidFloat(value) || !IsValidFloat(weight)) { - fprintf(stderr, "FromProto in histogram id %lu: skip bad value %f weight %f\n", Id, value, weight); + fprintf(stderr, "FromProto in histogram id %lu: skip bad value %f weight %f\n", Id, value, weight); continue; } Add(value, weight); } if (!IsValidFloat(histo.GetMinValue()) || !IsValidFloat(histo.GetMaxValue())) { - ythrow yexception() << Sprintf("FromProto in histogram id %lu: skip bad histo with minvalue %f maxvalue %f", Id, histo.GetMinValue(), histo.GetMaxValue()); + ythrow yexception() << Sprintf("FromProto in histogram id %lu: skip bad histo with minvalue %f maxvalue %f", Id, histo.GetMinValue(), histo.GetMaxValue()); } MinValue = histo.GetMinValue(); @@ -253,11 +253,11 @@ namespace NKiwiAggr { } } - void TAdaptiveHistogram::SetId(ui64 id) { + void TAdaptiveHistogram::SetId(ui64 id) { Id = id; } - ui64 TAdaptiveHistogram::GetId() { + ui64 TAdaptiveHistogram::GetId() { return Id; } @@ -430,20 +430,20 @@ namespace NKiwiAggr { } } - double TAdaptiveHistogram::CalcUpperBoundSafe(double sum) { - if (!Empty()) { - sum = Max(Bins.begin()->second, sum); - } - return CalcUpperBound(sum); - } - - double TAdaptiveHistogram::CalcLowerBoundSafe(double sum) { - if (!Empty()) { - sum = Max(Bins.rbegin()->second, sum); - } - return CalcLowerBound(sum); - } - + double TAdaptiveHistogram::CalcUpperBoundSafe(double sum) { + if (!Empty()) { + sum = Max(Bins.begin()->second, sum); + } + return CalcUpperBound(sum); + } + + double TAdaptiveHistogram::CalcLowerBoundSafe(double sum) { + if (!Empty()) { + sum = Max(Bins.rbegin()->second, sum); + } + return CalcLowerBound(sum); + } + void TAdaptiveHistogram::FromIHistogram(IHistogram* histo) { if (!histo) { ythrow yexception() << "Attempt to create TAdaptiveHistogram from a NULL pointer"; diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.h b/library/cpp/histogram/adaptive/adaptive_histogram.h index fa8f48433f..0737a62b95 100644 --- a/library/cpp/histogram/adaptive/adaptive_histogram.h +++ b/library/cpp/histogram/adaptive/adaptive_histogram.h @@ -38,7 +38,7 @@ namespace NKiwiAggr { } }; - ui64 Id; + ui64 Id; double MinValue; double MaxValue; double Sum; @@ -50,9 +50,9 @@ namespace NKiwiAggr { TVector<TFastBin> PrecomputedBins; public: - TAdaptiveHistogram(size_t intervals, ui64 id = 0, TQualityFunction qualityFunc = CalcWeightQuality); - TAdaptiveHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, TQualityFunction qualityFunc = nullptr); - TAdaptiveHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, TQualityFunction qualityFunc = CalcWeightQuality); + TAdaptiveHistogram(size_t intervals, ui64 id = 0, TQualityFunction qualityFunc = CalcWeightQuality); + TAdaptiveHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, TQualityFunction qualityFunc = nullptr); + TAdaptiveHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, TQualityFunction qualityFunc = CalcWeightQuality); ~TAdaptiveHistogram() override { } @@ -105,17 +105,17 @@ namespace NKiwiAggr { template <TQualityFunction QualityFunction> class TDefinedAdaptiveHistogram: public TAdaptiveHistogram { public: - TDefinedAdaptiveHistogram(size_t intervals, ui64 id = 0) + TDefinedAdaptiveHistogram(size_t intervals, ui64 id = 0) : TAdaptiveHistogram(intervals, id, QualityFunction) { } - TDefinedAdaptiveHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) + TDefinedAdaptiveHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) : TAdaptiveHistogram(histo, defaultIntervals, defaultId, QualityFunction) { } - TDefinedAdaptiveHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) + TDefinedAdaptiveHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) : TAdaptiveHistogram(histo, defaultIntervals, defaultId, QualityFunction) { } diff --git a/library/cpp/histogram/adaptive/auto_histogram.h b/library/cpp/histogram/adaptive/auto_histogram.h index 9fdf0b9abe..abd4c17603 100644 --- a/library/cpp/histogram/adaptive/auto_histogram.h +++ b/library/cpp/histogram/adaptive/auto_histogram.h @@ -14,25 +14,25 @@ namespace NKiwiAggr { private: static const size_t DEFAULT_INTERVALS = 100; - ui64 Id; + ui64 Id; size_t Intervals; THolder<IHistogram> HistogramImpl; public: - TAutoHistogram(size_t intervals, ui64 id = 0) { + TAutoHistogram(size_t intervals, ui64 id = 0) { Y_UNUSED(intervals); Y_UNUSED(id); ythrow yexception() << "Empty constructor is not defined for TAutoHistogram"; } - TAutoHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) + TAutoHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) : Id(defaultId) , Intervals(defaultIntervals) { FromProto(histo); } - TAutoHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) { + TAutoHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) { Y_UNUSED(histo); Y_UNUSED(defaultIntervals); Y_UNUSED(defaultId); @@ -88,11 +88,11 @@ namespace NKiwiAggr { HistogramImpl->ToProto(histo); } - virtual void SetId(ui64 id) { + virtual void SetId(ui64 id) { HistogramImpl->SetId(id); } - virtual ui64 GetId() { + virtual ui64 GetId() { return HistogramImpl->GetId(); } @@ -131,14 +131,14 @@ namespace NKiwiAggr { virtual double CalcLowerBound(double sum) { return HistogramImpl->CalcLowerBound(sum); } - - virtual double CalcUpperBoundSafe(double sum) { - return HistogramImpl->CalcUpperBoundSafe(sum); - } - - virtual double CalcLowerBoundSafe(double sum) { - return HistogramImpl->CalcLowerBoundSafe(sum); - } + + virtual double CalcUpperBoundSafe(double sum) { + return HistogramImpl->CalcUpperBoundSafe(sum); + } + + virtual double CalcLowerBoundSafe(double sum) { + return HistogramImpl->CalcLowerBoundSafe(sum); + } virtual void PrecomputePartialSums() { return HistogramImpl->PrecomputePartialSums(); diff --git a/library/cpp/histogram/adaptive/block_histogram.cpp b/library/cpp/histogram/adaptive/block_histogram.cpp index 6586d13ff6..779d90496c 100644 --- a/library/cpp/histogram/adaptive/block_histogram.cpp +++ b/library/cpp/histogram/adaptive/block_histogram.cpp @@ -82,7 +82,7 @@ namespace NKiwiAggr { /////////////////// TBlockHistogram::TBlockHistogram(EHistogramType type, TQualityFunction calcQuality, - size_t intervals, ui64 id, size_t shrinkSize) + size_t intervals, ui64 id, size_t shrinkSize) : Type(type) , CalcQuality(calcQuality) , Intervals(intervals) @@ -112,7 +112,7 @@ namespace NKiwiAggr { void TBlockHistogram::Add(double value, double weight) { if (!IsValidFloat(value) || !IsValidFloat(weight)) { - ythrow yexception() << Sprintf("Histogram id %lu: bad value %f weight %f", Id, value, weight); + ythrow yexception() << Sprintf("Histogram id %lu: bad value %f weight %f", Id, value, weight); } if (weight <= 0.0) { @@ -138,7 +138,7 @@ namespace NKiwiAggr { void TBlockHistogram::Merge(const THistogram& histo, double multiplier) { if (!IsValidFloat(histo.GetMinValue()) || !IsValidFloat(histo.GetMaxValue())) { - fprintf(stderr, "Merging in histogram id %lu: skip bad histo with minvalue %f maxvalue %f\n", Id, histo.GetMinValue(), histo.GetMaxValue()); + fprintf(stderr, "Merging in histogram id %lu: skip bad histo with minvalue %f maxvalue %f\n", Id, histo.GetMinValue(), histo.GetMaxValue()); return; } if (histo.FreqSize() == 0) { @@ -154,7 +154,7 @@ namespace NKiwiAggr { double value = histo.GetPosition(j); double weight = histo.GetFreq(j); if (!IsValidFloat(value) || !IsValidFloat(weight)) { - fprintf(stderr, "Merging in histogram id %lu: skip bad value %f weight %f\n", Id, value, weight); + fprintf(stderr, "Merging in histogram id %lu: skip bad value %f weight %f\n", Id, value, weight); continue; } Add(value, weight * multiplier); @@ -167,7 +167,7 @@ namespace NKiwiAggr { for (size_t j = 0; j < histo.FreqSize(); ++j) { double weight = histo.GetFreq(j); if (!IsValidFloat(pos) || !IsValidFloat(weight)) { - fprintf(stderr, "Merging in histogram id %lu: skip bad value %f weight %f\n", Id, pos, weight); + fprintf(stderr, "Merging in histogram id %lu: skip bad value %f weight %f\n", Id, pos, weight); pos += histo.GetBinRange(); continue; } @@ -229,7 +229,7 @@ namespace NKiwiAggr { double value = histo.GetPosition(i); double weight = histo.GetFreq(i); if (!IsValidFloat(value) || !IsValidFloat(weight)) { - fprintf(stderr, "FromProto in histogram id %lu: skip bad value %f weight %f\n", Id, value, weight); + fprintf(stderr, "FromProto in histogram id %lu: skip bad value %f weight %f\n", Id, value, weight); continue; } Bins[i].first = value; @@ -238,7 +238,7 @@ namespace NKiwiAggr { } if (!IsValidFloat(histo.GetMinValue()) || !IsValidFloat(histo.GetMaxValue())) { - ythrow yexception() << Sprintf("FromProto in histogram id %lu: skip bad histo with minvalue %f maxvalue %f", Id, histo.GetMinValue(), histo.GetMaxValue()); + ythrow yexception() << Sprintf("FromProto in histogram id %lu: skip bad histo with minvalue %f maxvalue %f", Id, histo.GetMinValue(), histo.GetMaxValue()); } MinValue = histo.GetMinValue(); MaxValue = histo.GetMaxValue(); @@ -261,11 +261,11 @@ namespace NKiwiAggr { } } - void TBlockHistogram::SetId(ui64 id) { + void TBlockHistogram::SetId(ui64 id) { Id = id; } - ui64 TBlockHistogram::GetId() { + ui64 TBlockHistogram::GetId() { return Id; } @@ -445,23 +445,23 @@ namespace NKiwiAggr { return 0; } - double TBlockHistogram::CalcUpperBoundSafe(double sum) { + double TBlockHistogram::CalcUpperBoundSafe(double sum) { Y_UNUSED(sum); - ythrow yexception() << "Method is not implemented for TBlockHistogram"; - return 0; - } + ythrow yexception() << "Method is not implemented for TBlockHistogram"; + return 0; + } - double TBlockHistogram::CalcLowerBoundSafe(double sum) { + double TBlockHistogram::CalcLowerBoundSafe(double sum) { Y_UNUSED(sum); - ythrow yexception() << "Method is not implemented for TBlockHistogram"; - return 0; - } - + ythrow yexception() << "Method is not implemented for TBlockHistogram"; + return 0; + } + ///////////////////////// // TBlockWeightHistogram ///////////////////////// - TBlockWeightHistogram::TBlockWeightHistogram(size_t intervals, ui64 id, size_t shrinkSize) + TBlockWeightHistogram::TBlockWeightHistogram(size_t intervals, ui64 id, size_t shrinkSize) : TBlockHistogram(HT_ADAPTIVE_WEIGHT_HISTOGRAM, CalcWeightQuality, intervals, id, shrinkSize) { } @@ -494,7 +494,7 @@ namespace NKiwiAggr { // TBlockWardHistogram /////////////////////// - TBlockWardHistogram::TBlockWardHistogram(size_t intervals, ui64 id, size_t shrinkSize) + TBlockWardHistogram::TBlockWardHistogram(size_t intervals, ui64 id, size_t shrinkSize) : TBlockHistogram(HT_ADAPTIVE_WARD_HISTOGRAM, CalcWardQuality, intervals, id, shrinkSize) { } diff --git a/library/cpp/histogram/adaptive/block_histogram.h b/library/cpp/histogram/adaptive/block_histogram.h index 266bb2f2b2..3588185fef 100644 --- a/library/cpp/histogram/adaptive/block_histogram.h +++ b/library/cpp/histogram/adaptive/block_histogram.h @@ -39,7 +39,7 @@ namespace NKiwiAggr { size_t ShrinkSize; size_t PrevSize; - ui64 Id; + ui64 Id; double Sum; double MinValue; @@ -49,7 +49,7 @@ namespace NKiwiAggr { public: TBlockHistogram(EHistogramType type, TQualityFunction calcQuality, - size_t intervals, ui64 id = 0, size_t shrinkSize = DEFAULT_SHRINK_SIZE); + size_t intervals, ui64 id = 0, size_t shrinkSize = DEFAULT_SHRINK_SIZE); virtual ~TBlockHistogram() { } @@ -68,8 +68,8 @@ namespace NKiwiAggr { virtual void FromProto(const THistogram& histo); virtual void ToProto(THistogram& histo); - virtual void SetId(ui64 id); - virtual ui64 GetId(); + virtual void SetId(ui64 id); + virtual ui64 GetId(); virtual bool Empty(); virtual double GetMinValue(); virtual double GetMaxValue(); @@ -81,8 +81,8 @@ namespace NKiwiAggr { virtual double GetSumBelowBound(double bound); virtual double CalcUpperBound(double sum); virtual double CalcLowerBound(double sum); - virtual double CalcUpperBoundSafe(double sum); - virtual double CalcLowerBoundSafe(double sum); + virtual double CalcUpperBoundSafe(double sum); + virtual double CalcLowerBoundSafe(double sum); private: void SortBins(); @@ -101,7 +101,7 @@ namespace NKiwiAggr { class TBlockWeightHistogram: public TBlockHistogram { public: - TBlockWeightHistogram(size_t intervals, ui64 id = 0, size_t shrinkSize = DEFAULT_SHRINK_SIZE); + TBlockWeightHistogram(size_t intervals, ui64 id = 0, size_t shrinkSize = DEFAULT_SHRINK_SIZE); virtual ~TBlockWeightHistogram() { } @@ -116,7 +116,7 @@ namespace NKiwiAggr { class TBlockWardHistogram: public TBlockHistogram { public: - TBlockWardHistogram(size_t intervals, ui64 id = 0, size_t shrinkSize = DEFAULT_SHRINK_SIZE); + TBlockWardHistogram(size_t intervals, ui64 id = 0, size_t shrinkSize = DEFAULT_SHRINK_SIZE); virtual ~TBlockWardHistogram() { } diff --git a/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp b/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp index 558aba9e2d..e8dd6e6103 100644 --- a/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp +++ b/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp @@ -9,7 +9,7 @@ #include <util/string/printf.h> namespace NKiwiAggr { - TFixedBinHistogram::TFixedBinHistogram(size_t intervals, ui64 id, size_t trainingSetSize) + TFixedBinHistogram::TFixedBinHistogram(size_t intervals, ui64 id, size_t trainingSetSize) : TrainingSetSize(trainingSetSize) , IsInitialized(false) , IsEmpty(true) @@ -23,7 +23,7 @@ namespace NKiwiAggr { { } - TFixedBinHistogram::TFixedBinHistogram(const THistogram& histo, size_t defaultIntervals, ui64 defaultId, size_t trainingSetSize) + TFixedBinHistogram::TFixedBinHistogram(const THistogram& histo, size_t defaultIntervals, ui64 defaultId, size_t trainingSetSize) : TrainingSetSize(trainingSetSize) , IsInitialized(false) , IsEmpty(true) @@ -38,7 +38,7 @@ namespace NKiwiAggr { FromProto(histo); } - TFixedBinHistogram::TFixedBinHistogram(IHistogram* histo, size_t defaultIntervals, ui64 defaultId, size_t trainingSetSize) + TFixedBinHistogram::TFixedBinHistogram(IHistogram* histo, size_t defaultIntervals, ui64 defaultId, size_t trainingSetSize) : TrainingSetSize(trainingSetSize) , IsInitialized(false) , IsEmpty(true) @@ -91,7 +91,7 @@ namespace NKiwiAggr { void TFixedBinHistogram::Add(double value, double weight) { if (!IsValidFloat(value) || !IsValidFloat(weight)) { - ythrow yexception() << Sprintf("Histogram id %lu: bad value %f weight %f", Id, value, weight); + ythrow yexception() << Sprintf("Histogram id %lu: bad value %f weight %f", Id, value, weight); } if (weight <= 0.0) { @@ -237,7 +237,7 @@ namespace NKiwiAggr { BaseIndex = Intervals / 2; if (!IsValidFloat(histo.GetMinValue()) || !IsValidFloat(histo.GetMaxValue()) || !IsValidFloat(histo.GetBinRange())) { - ythrow yexception() << Sprintf("FromProto in histogram id %lu: skip bad histo with minvalue %f maxvalue %f binrange %f", Id, histo.GetMinValue(), histo.GetMaxValue(), histo.GetBinRange()); + ythrow yexception() << Sprintf("FromProto in histogram id %lu: skip bad histo with minvalue %f maxvalue %f binrange %f", Id, histo.GetMinValue(), histo.GetMaxValue(), histo.GetBinRange()); } double minValue = histo.GetMinValue(); @@ -248,7 +248,7 @@ namespace NKiwiAggr { for (i32 i = FirstUsedBin; i <= LastUsedBin; ++i) { Freqs[i] = histo.GetFreq(i - BaseIndex); if (!IsValidFloat(Freqs[i])) { - ythrow yexception() << Sprintf("FromProto in histogram id %lu: bad value %f", Id, Freqs[i]); + ythrow yexception() << Sprintf("FromProto in histogram id %lu: bad value %f", Id, Freqs[i]); } Sum += Freqs[i]; } @@ -275,11 +275,11 @@ namespace NKiwiAggr { } } - void TFixedBinHistogram::SetId(ui64 id) { + void TFixedBinHistogram::SetId(ui64 id) { Id = id; } - ui64 TFixedBinHistogram::GetId() { + ui64 TFixedBinHistogram::GetId() { return Id; } @@ -374,9 +374,9 @@ namespace NKiwiAggr { if (!IsInitialized) { Initialize(); } - if (sum == 0.0) { - return MinValue; - } + if (sum == 0.0) { + return MinValue; + } if (IsEmpty) { return MaxValue; } @@ -387,7 +387,7 @@ namespace NKiwiAggr { ++currentBin; } --currentBin; - if ((gatheredSum <= sum && currentBin == LastUsedBin) || (Freqs[currentBin] == 0)) { + if ((gatheredSum <= sum && currentBin == LastUsedBin) || (Freqs[currentBin] == 0)) { return MaxValue; } double binStart = BinStart(currentBin); @@ -399,9 +399,9 @@ namespace NKiwiAggr { if (!IsInitialized) { Initialize(); } - if (sum == 0.0) { - return MaxValue; - } + if (sum == 0.0) { + return MaxValue; + } if (IsEmpty) { return MinValue; } @@ -412,7 +412,7 @@ namespace NKiwiAggr { --currentBin; } ++currentBin; - if ((gatheredSum <= sum && currentBin == FirstUsedBin) || (Freqs[currentBin] == 0)) { + if ((gatheredSum <= sum && currentBin == FirstUsedBin) || (Freqs[currentBin] == 0)) { return MinValue; } double binStart = BinStart(currentBin); @@ -420,20 +420,20 @@ namespace NKiwiAggr { return binStart + (binEnd - binStart) * (gatheredSum - sum) / Freqs[currentBin]; } - double TFixedBinHistogram::CalcUpperBoundSafe(double sum) { - if (!Empty()) { - sum = Max(Freqs[FirstUsedBin], sum); - } - return CalcUpperBound(sum); - } - - double TFixedBinHistogram::CalcLowerBoundSafe(double sum) { - if (!Empty()) { - sum = Max(Freqs[LastUsedBin], sum); - } - return CalcLowerBound(sum); - } - + double TFixedBinHistogram::CalcUpperBoundSafe(double sum) { + if (!Empty()) { + sum = Max(Freqs[FirstUsedBin], sum); + } + return CalcUpperBound(sum); + } + + double TFixedBinHistogram::CalcLowerBoundSafe(double sum) { + if (!Empty()) { + sum = Max(Freqs[LastUsedBin], sum); + } + return CalcLowerBound(sum); + } + double TFixedBinHistogram::CalcBinRange(double referencePoint, double maxValue) { return (maxValue - referencePoint) / ((double)Intervals - 0.02); } diff --git a/library/cpp/histogram/adaptive/fixed_bin_histogram.h b/library/cpp/histogram/adaptive/fixed_bin_histogram.h index bd380bd94a..7404bddd9a 100644 --- a/library/cpp/histogram/adaptive/fixed_bin_histogram.h +++ b/library/cpp/histogram/adaptive/fixed_bin_histogram.h @@ -21,7 +21,7 @@ namespace NKiwiAggr { bool IsInitialized; bool IsEmpty; - ui64 Id; + ui64 Id; double MinValue; double MaxValue; double Sum; @@ -36,9 +36,9 @@ namespace NKiwiAggr { i32 BaseIndex; public: - TFixedBinHistogram(size_t intervals, ui64 id = 0, size_t trainingSetSize = DEFAULT_TRAINING_SET_SIZE); - TFixedBinHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, size_t trainingSetSize = DEFAULT_TRAINING_SET_SIZE); - TFixedBinHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, size_t trainingSetSize = DEFAULT_TRAINING_SET_SIZE); + TFixedBinHistogram(size_t intervals, ui64 id = 0, size_t trainingSetSize = DEFAULT_TRAINING_SET_SIZE); + TFixedBinHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, size_t trainingSetSize = DEFAULT_TRAINING_SET_SIZE); + TFixedBinHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, size_t trainingSetSize = DEFAULT_TRAINING_SET_SIZE); virtual ~TFixedBinHistogram() { } @@ -57,8 +57,8 @@ namespace NKiwiAggr { virtual void FromProto(const THistogram& histo); virtual void ToProto(THistogram& histo); - virtual void SetId(ui64 id); - virtual ui64 GetId(); + virtual void SetId(ui64 id); + virtual ui64 GetId(); virtual bool Empty(); virtual double GetMinValue(); virtual double GetMaxValue(); @@ -68,8 +68,8 @@ namespace NKiwiAggr { virtual double GetSumBelowBound(double bound); virtual double CalcUpperBound(double sum); virtual double CalcLowerBound(double sum); - virtual double CalcUpperBoundSafe(double sum); - virtual double CalcLowerBoundSafe(double sum); + virtual double CalcUpperBoundSafe(double sum); + virtual double CalcLowerBoundSafe(double sum); double CalcDensity(double value); diff --git a/library/cpp/histogram/adaptive/histogram.h b/library/cpp/histogram/adaptive/histogram.h index 360fd9a693..fb8d0984b3 100644 --- a/library/cpp/histogram/adaptive/histogram.h +++ b/library/cpp/histogram/adaptive/histogram.h @@ -14,7 +14,7 @@ namespace NKiwiAggr { public: // Supposed constructors: // - // TSomeHistogram(size_t intervals, ui64 id = 0); // where intervals is some constant that defines histogram accuracy + // TSomeHistogram(size_t intervals, ui64 id = 0); // where intervals is some constant that defines histogram accuracy // TSomeHistogram(const THistogram& histo); // histo must be acceptable for TSomeHistogram, for example, only with HT_FIXED_BIN_HISTOGRAM for TFixedBinHistogram // TSomeHistogram(IHistogram* histo); // any kind of IHistogram @@ -38,8 +38,8 @@ namespace NKiwiAggr { virtual void FromProto(const THistogram& histo) = 0; // throws exception in case of wrong histogram type of histo virtual void ToProto(THistogram& histo) = 0; - virtual void SetId(ui64 id) = 0; - virtual ui64 GetId() = 0; + virtual void SetId(ui64 id) = 0; + virtual ui64 GetId() = 0; virtual bool Empty() = 0; virtual double GetMinValue() = 0; virtual double GetMaxValue() = 0; @@ -49,8 +49,8 @@ namespace NKiwiAggr { virtual double GetSumBelowBound(double bound) = 0; virtual double CalcUpperBound(double sum) = 0; virtual double CalcLowerBound(double sum) = 0; - virtual double CalcUpperBoundSafe(double sum) = 0; - virtual double CalcLowerBoundSafe(double sum) = 0; + virtual double CalcUpperBoundSafe(double sum) = 0; + virtual double CalcLowerBoundSafe(double sum) = 0; double GetValueAtPercentile(double percentile) { return CalcUpperBound(percentile * GetSum()); } diff --git a/library/cpp/histogram/adaptive/multi_histogram.h b/library/cpp/histogram/adaptive/multi_histogram.h index 41caac5ba6..54ae1463e5 100644 --- a/library/cpp/histogram/adaptive/multi_histogram.h +++ b/library/cpp/histogram/adaptive/multi_histogram.h @@ -48,7 +48,7 @@ namespace NKiwiAggr { Add(histoRec.GetId(), histoRec.GetValue(), histoRec.GetWeight()); } - void Add(ui64 id, double value, double weight) { + void Add(ui64 id, double value, double weight) { THistogramsMap::const_iterator it = Histograms.find(id); if (it == Histograms.end()) { it = Histograms.insert(std::make_pair(id, IHistogramPtr(new TMyHistogram(Intervals, id)))).first; @@ -70,7 +70,7 @@ namespace NKiwiAggr { return result; } - IHistogramPtr GetHistogram(ui64 id) const { + IHistogramPtr GetHistogram(ui64 id) const { THistogramsMap::const_iterator it = Histograms.find(id); if (it != Histograms.end()) { return it->second; diff --git a/library/cpp/monlib/deprecated/json/writer.cpp b/library/cpp/monlib/deprecated/json/writer.cpp index a581f2e07a..acbaecb1f1 100644 --- a/library/cpp/monlib/deprecated/json/writer.cpp +++ b/library/cpp/monlib/deprecated/json/writer.cpp @@ -35,18 +35,18 @@ namespace NMonitoring { TransitionState(STATE_COMMON_LABELS, STATE_DOCUMENT); JsonWriter.CloseMap(); } - + void TDeprecatedJsonWriter::WriteCommonLabel(TStringBuf name, TStringBuf value) { TransitionState(STATE_COMMON_LABELS, STATE_COMMON_LABELS); JsonWriter.Write(name, value); } - + void TDeprecatedJsonWriter::OpenMetrics() { TransitionState(STATE_DOCUMENT, STATE_METRICS); JsonWriter.Write("sensors"); JsonWriter.OpenArray(); } - + void TDeprecatedJsonWriter::CloseMetrics() { TransitionState(STATE_METRICS, STATE_DOCUMENT); JsonWriter.CloseArray(); diff --git a/library/cpp/monlib/deprecated/json/writer.h b/library/cpp/monlib/deprecated/json/writer.h index 183288143c..dea61323ea 100644 --- a/library/cpp/monlib/deprecated/json/writer.h +++ b/library/cpp/monlib/deprecated/json/writer.h @@ -17,7 +17,7 @@ namespace NMonitoring { enum EState { STATE_ROOT, STATE_DOCUMENT, - STATE_COMMON_LABELS, + STATE_COMMON_LABELS, STATE_METRICS, STATE_METRIC, STATE_LABELS, @@ -30,11 +30,11 @@ namespace NMonitoring { void OpenDocument(); void CloseDocument(); - void OpenCommonLabels(); - void CloseCommonLabels(); - - void WriteCommonLabel(TStringBuf name, TStringBuf value); - + void OpenCommonLabels(); + void CloseCommonLabels(); + + void WriteCommonLabel(TStringBuf name, TStringBuf value); + void OpenMetrics(); void CloseMetrics(); @@ -57,8 +57,8 @@ namespace NMonitoring { void WriteValue(long long value); void WriteDoubleValue(double d); - - void WriteTs(ui64 ts); + + void WriteTs(ui64 ts); private: void WriteLabelsInner(TStringBuf name, TStringBuf value) { diff --git a/library/cpp/monlib/dynamic_counters/page.h b/library/cpp/monlib/dynamic_counters/page.h index 1f0ef6a5ea..ddb0994d3b 100644 --- a/library/cpp/monlib/dynamic_counters/page.h +++ b/library/cpp/monlib/dynamic_counters/page.h @@ -27,15 +27,15 @@ namespace NMonitoring { void HandleAbsentSubgroup(IMonHttpRequest& request); public: - TDynamicCountersPage(const TString& path, + TDynamicCountersPage(const TString& path, const TString& title, - TIntrusivePtr<TDynamicCounters> counters, + TIntrusivePtr<TDynamicCounters> counters, TOutputCallback outputCallback = nullptr) : TPreMonPage(path, title) , Counters(counters) , OutputCallback(outputCallback) - { - } + { + } void Output(NMonitoring::IMonHttpRequest& request) override; |