aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/histogram/adaptive/adaptive_histogram.h
diff options
context:
space:
mode:
authorzosimov <zosimov@yandex-team.ru>2022-02-10 16:50:32 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:32 +0300
commita8f009e06d613c9567eb4c0f461dbed5e0d8092b (patch)
treed21fc5cd2e0d5ade9588ebc637729e86b924279b /library/cpp/histogram/adaptive/adaptive_histogram.h
parent06e925754c8de946ff79d538bde1e6424cbd4cbb (diff)
downloadydb-a8f009e06d613c9567eb4c0f461dbed5e0d8092b.tar.gz
Restoring authorship annotation for <zosimov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/histogram/adaptive/adaptive_histogram.h')
-rw-r--r--library/cpp/histogram/adaptive/adaptive_histogram.h120
1 files changed, 60 insertions, 60 deletions
diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.h b/library/cpp/histogram/adaptive/adaptive_histogram.h
index fa8f48433f..daf772584a 100644
--- a/library/cpp/histogram/adaptive/adaptive_histogram.h
+++ b/library/cpp/histogram/adaptive/adaptive_histogram.h
@@ -1,22 +1,22 @@
-#pragma once
-
-#include "histogram.h"
+#pragma once
+
+#include "histogram.h"
#include "common.h"
-
+
#include <library/cpp/histogram/adaptive/protos/histo.pb.h>
-
-#include <util/generic/ptr.h>
-#include <util/generic/set.h>
-#include <util/generic/vector.h>
-
-namespace NKiwiAggr {
+
+#include <util/generic/ptr.h>
+#include <util/generic/set.h>
+#include <util/generic/vector.h>
+
+namespace NKiwiAggr {
class TAdaptiveHistogram: private TNonCopyable, public IHistogram {
- protected:
- static const size_t DEFAULT_INTERVALS = 100;
-
- private:
+ protected:
+ static const size_t DEFAULT_INTERVALS = 100;
+
+ private:
using TPairSet = TSet<TWeightedValue>;
-
+
struct TFastBin {
// these names are for compatibility with TWeightedValue
double first;
@@ -39,40 +39,40 @@ namespace NKiwiAggr {
};
ui64 Id;
- double MinValue;
- double MaxValue;
- double Sum;
- size_t Intervals;
- TPairSet Bins;
- TPairSet BinsByQuality;
- TQualityFunction CalcQuality;
-
+ double MinValue;
+ double MaxValue;
+ double Sum;
+ size_t Intervals;
+ TPairSet Bins;
+ TPairSet BinsByQuality;
+ TQualityFunction CalcQuality;
+
TVector<TFastBin> PrecomputedBins;
- public:
+ 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() override {
- }
-
- TQualityFunction GetQualityFunc();
-
+ }
+
+ TQualityFunction GetQualityFunc();
+
void Clear() override;
-
+
void Add(double value, double weight) override;
void Add(const THistoRec& histoRec) override;
-
+
void Merge(const THistogram& histo, double multiplier) final;
void Merge(const TVector<THistogram>& histogramsToMerge) final;
void Merge(TVector<IHistogramPtr> histogramsToMerge) final;
-
+
void Multiply(double factor) final;
-
+
void FromProto(const THistogram& histo) final;
void ToProto(THistogram& histo) final;
-
+
void SetId(ui64 id) final;
ui64 GetId() final;
bool Empty() final;
@@ -86,46 +86,46 @@ namespace NKiwiAggr {
double CalcLowerBound(double sum) final;
double CalcUpperBoundSafe(double sum) final;
double CalcLowerBoundSafe(double sum) final;
-
+
void PrecomputePartialSums() final;
- private:
- void FromIHistogram(IHistogram* histo);
- void Add(const TWeightedValue& weightedValue, bool initial);
- void Erase(double value);
- void Shrink();
+ private:
+ void FromIHistogram(IHistogram* histo);
+ void Add(const TWeightedValue& weightedValue, bool initial);
+ void Erase(double value);
+ void Shrink();
template <typename TBins, typename TGetSumAbove>
double GetSumAboveBoundImpl(double bound, const TBins& bins, typename TBins::const_iterator rightBin, const TGetSumAbove& getSumAbove) const;
template <typename TBins, typename TGetSumBelow>
double GetSumBelowBoundImpl(double bound, const TBins& bins, typename TBins::const_iterator rightBin, const TGetSumBelow& getSumBelow) const;
- };
-
+ };
+
template <TQualityFunction QualityFunction>
- class TDefinedAdaptiveHistogram: public TAdaptiveHistogram {
- public:
+ class TDefinedAdaptiveHistogram: public TAdaptiveHistogram {
+ public:
TDefinedAdaptiveHistogram(size_t intervals, ui64 id = 0)
- : TAdaptiveHistogram(intervals, id, QualityFunction)
- {
- }
-
+ : TAdaptiveHistogram(intervals, id, QualityFunction)
+ {
+ }
+
TDefinedAdaptiveHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0)
- : TAdaptiveHistogram(histo, defaultIntervals, defaultId, QualityFunction)
- {
- }
-
+ : TAdaptiveHistogram(histo, defaultIntervals, defaultId, QualityFunction)
+ {
+ }
+
TDefinedAdaptiveHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0)
- : TAdaptiveHistogram(histo, defaultIntervals, defaultId, QualityFunction)
- {
- }
-
+ : TAdaptiveHistogram(histo, defaultIntervals, defaultId, QualityFunction)
+ {
+ }
+
~TDefinedAdaptiveHistogram() override {
- }
- };
-
+ }
+ };
+
typedef TDefinedAdaptiveHistogram<CalcDistanceQuality> TAdaptiveDistanceHistogram;
typedef TDefinedAdaptiveHistogram<CalcWeightQuality> TAdaptiveWeightHistogram;
typedef TDefinedAdaptiveHistogram<CalcWardQuality> TAdaptiveWardHistogram;
-
+
}