diff options
author | zosimov <zosimov@yandex-team.ru> | 2022-02-10 16:50:32 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:32 +0300 |
commit | a8f009e06d613c9567eb4c0f461dbed5e0d8092b (patch) | |
tree | d21fc5cd2e0d5ade9588ebc637729e86b924279b /library/cpp/histogram/adaptive/auto_histogram.h | |
parent | 06e925754c8de946ff79d538bde1e6424cbd4cbb (diff) | |
download | ydb-a8f009e06d613c9567eb4c0f461dbed5e0d8092b.tar.gz |
Restoring authorship annotation for <zosimov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/histogram/adaptive/auto_histogram.h')
-rw-r--r-- | library/cpp/histogram/adaptive/auto_histogram.h | 216 |
1 files changed, 108 insertions, 108 deletions
diff --git a/library/cpp/histogram/adaptive/auto_histogram.h b/library/cpp/histogram/adaptive/auto_histogram.h index 9fdf0b9abe..57c4c7b7fe 100644 --- a/library/cpp/histogram/adaptive/auto_histogram.h +++ b/library/cpp/histogram/adaptive/auto_histogram.h @@ -1,136 +1,136 @@ -#pragma once - -#include "adaptive_histogram.h" -#include "fixed_bin_histogram.h" -#include "histogram.h" - +#pragma once + +#include "adaptive_histogram.h" +#include "fixed_bin_histogram.h" +#include "histogram.h" + #include <library/cpp/histogram/adaptive/protos/histo.pb.h> - -#include <util/generic/ptr.h> + +#include <util/generic/ptr.h> #include <util/generic/yexception.h> - -namespace NKiwiAggr { + +namespace NKiwiAggr { class TAutoHistogram: private TNonCopyable, public IHistogram { - private: - static const size_t DEFAULT_INTERVALS = 100; - + private: + static const size_t DEFAULT_INTERVALS = 100; + ui64 Id; - size_t Intervals; - THolder<IHistogram> HistogramImpl; - - public: + size_t Intervals; + THolder<IHistogram> HistogramImpl; + + public: TAutoHistogram(size_t intervals, ui64 id = 0) { Y_UNUSED(intervals); Y_UNUSED(id); - ythrow yexception() << "Empty constructor is not defined for TAutoHistogram"; - } - + ythrow yexception() << "Empty constructor is not defined for TAutoHistogram"; + } + TAutoHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) - : Id(defaultId) - , Intervals(defaultIntervals) - { - FromProto(histo); - } - + : Id(defaultId) + , Intervals(defaultIntervals) + { + FromProto(histo); + } + TAutoHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) { Y_UNUSED(histo); Y_UNUSED(defaultIntervals); Y_UNUSED(defaultId); - ythrow yexception() << "IHistogram constructor is not defined for TAutoHistogram"; - } - + ythrow yexception() << "IHistogram constructor is not defined for TAutoHistogram"; + } + virtual ~TAutoHistogram() { - } - - virtual void Clear() { - HistogramImpl->Clear(); - } - - virtual void Add(double value, double weight) { - HistogramImpl->Add(value, weight); - } - - virtual void Add(const THistoRec& histoRec) { - HistogramImpl->Add(histoRec); - } - + } + + virtual void Clear() { + HistogramImpl->Clear(); + } + + virtual void Add(double value, double weight) { + HistogramImpl->Add(value, weight); + } + + virtual void Add(const THistoRec& histoRec) { + HistogramImpl->Add(histoRec); + } + virtual void Merge(const THistogram& histo, double multiplier) { HistogramImpl->Merge(histo, multiplier); } virtual void Merge(const TVector<THistogram>& histogramsToMerge) { - HistogramImpl->Merge(histogramsToMerge); - } - + HistogramImpl->Merge(histogramsToMerge); + } + virtual void Merge(TVector<IHistogramPtr> histogramsToMerge) { - HistogramImpl->Merge(histogramsToMerge); - } - - virtual void Multiply(double factor) { - HistogramImpl->Multiply(factor); - } - - virtual void FromProto(const THistogram& histo) { - if (!histo.HasType() || histo.GetType() == HT_FIXED_BIN_HISTOGRAM) { - HistogramImpl.Reset(new TFixedBinHistogram(histo, Intervals, Id)); + HistogramImpl->Merge(histogramsToMerge); + } + + virtual void Multiply(double factor) { + HistogramImpl->Multiply(factor); + } + + virtual void FromProto(const THistogram& histo) { + if (!histo.HasType() || histo.GetType() == HT_FIXED_BIN_HISTOGRAM) { + HistogramImpl.Reset(new TFixedBinHistogram(histo, Intervals, Id)); } else if (histo.GetType() == HT_ADAPTIVE_DISTANCE_HISTOGRAM) { - HistogramImpl.Reset(new TAdaptiveDistanceHistogram(histo, Intervals, Id)); + HistogramImpl.Reset(new TAdaptiveDistanceHistogram(histo, Intervals, Id)); } else if (histo.GetType() == HT_ADAPTIVE_WEIGHT_HISTOGRAM) { - HistogramImpl.Reset(new TAdaptiveWeightHistogram(histo, Intervals, Id)); + HistogramImpl.Reset(new TAdaptiveWeightHistogram(histo, Intervals, Id)); } else if (histo.GetType() == HT_ADAPTIVE_WARD_HISTOGRAM) { HistogramImpl.Reset(new TAdaptiveWardHistogram(histo, Intervals, Id)); } else { ythrow yexception() << "Can't parse TAutoHistogram from a THistogram of type " << (ui32)histo.GetType(); - } - } - - virtual void ToProto(THistogram& histo) { - HistogramImpl->ToProto(histo); - } - + } + } + + virtual void ToProto(THistogram& histo) { + HistogramImpl->ToProto(histo); + } + virtual void SetId(ui64 id) { - HistogramImpl->SetId(id); - } - + HistogramImpl->SetId(id); + } + virtual ui64 GetId() { - return HistogramImpl->GetId(); - } - - virtual bool Empty() { - return HistogramImpl->Empty(); - } - - virtual double GetMinValue() { - return HistogramImpl->GetMinValue(); - } - - virtual double GetMaxValue() { - return HistogramImpl->GetMaxValue(); - } - - virtual double GetSum() { - return HistogramImpl->GetSum(); - } - - virtual double GetSumInRange(double leftBound, double rightBound) { - return HistogramImpl->GetSumInRange(leftBound, rightBound); - } - - virtual double GetSumAboveBound(double bound) { - return HistogramImpl->GetSumAboveBound(bound); - } - - virtual double GetSumBelowBound(double bound) { - return HistogramImpl->GetSumBelowBound(bound); - } - - virtual double CalcUpperBound(double sum) { - return HistogramImpl->CalcUpperBound(sum); - } - - virtual double CalcLowerBound(double sum) { - return HistogramImpl->CalcLowerBound(sum); - } + return HistogramImpl->GetId(); + } + + virtual bool Empty() { + return HistogramImpl->Empty(); + } + + virtual double GetMinValue() { + return HistogramImpl->GetMinValue(); + } + + virtual double GetMaxValue() { + return HistogramImpl->GetMaxValue(); + } + + virtual double GetSum() { + return HistogramImpl->GetSum(); + } + + virtual double GetSumInRange(double leftBound, double rightBound) { + return HistogramImpl->GetSumInRange(leftBound, rightBound); + } + + virtual double GetSumAboveBound(double bound) { + return HistogramImpl->GetSumAboveBound(bound); + } + + virtual double GetSumBelowBound(double bound) { + return HistogramImpl->GetSumBelowBound(bound); + } + + virtual double CalcUpperBound(double sum) { + return HistogramImpl->CalcUpperBound(sum); + } + + virtual double CalcLowerBound(double sum) { + return HistogramImpl->CalcLowerBound(sum); + } virtual double CalcUpperBoundSafe(double sum) { return HistogramImpl->CalcUpperBoundSafe(sum); @@ -143,6 +143,6 @@ namespace NKiwiAggr { virtual void PrecomputePartialSums() { return HistogramImpl->PrecomputePartialSums(); } - }; - + }; + } |