aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/histogram/adaptive/block_histogram.h
diff options
context:
space:
mode:
authoraprudaev <aprudaev@yandex-team.ru>2022-02-10 16:49:58 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:58 +0300
commit29e66fe2ab37743577f88e6ab770defc4e6c1002 (patch)
tree332323481b37f79cf521451582f724fb13a7143a /library/cpp/histogram/adaptive/block_histogram.h
parent66f1a2f0600877a21fcc76f83c52904a58425f78 (diff)
downloadydb-29e66fe2ab37743577f88e6ab770defc4e6c1002.tar.gz
Restoring authorship annotation for <aprudaev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/histogram/adaptive/block_histogram.h')
-rw-r--r--library/cpp/histogram/adaptive/block_histogram.h104
1 files changed, 52 insertions, 52 deletions
diff --git a/library/cpp/histogram/adaptive/block_histogram.h b/library/cpp/histogram/adaptive/block_histogram.h
index 266bb2f2b2..dda8623c63 100644
--- a/library/cpp/histogram/adaptive/block_histogram.h
+++ b/library/cpp/histogram/adaptive/block_histogram.h
@@ -1,19 +1,19 @@
-#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/vector.h>
+
+#include <util/generic/ptr.h>
+#include <util/generic/vector.h>
#include <utility>
-
-namespace NKiwiAggr {
+
+namespace NKiwiAggr {
///////////////////
// TBlockHistogram
///////////////////
-
+
/**
* Contrary to adaptive histogram, block histogram doesn't rebuild bins
* after the addition of each point. Instead, it accumulates points and in case the amount
@@ -28,73 +28,73 @@ namespace NKiwiAggr {
class TBlockHistogram: private TNonCopyable, public IHistogram {
protected:
static const size_t SHRINK_MULTIPLIER = 2;
- static const size_t GREEDY_SHRINK_MULTIPLIER = 4;
+ static const size_t GREEDY_SHRINK_MULTIPLIER = 4;
static const size_t DEFAULT_INTERVALS = 100;
static const size_t DEFAULT_SHRINK_SIZE = DEFAULT_INTERVALS * (SHRINK_MULTIPLIER + GREEDY_SHRINK_MULTIPLIER);
-
+
const EHistogramType Type;
const TQualityFunction CalcQuality;
- size_t Intervals;
- size_t ShrinkSize;
- size_t PrevSize;
-
+ size_t Intervals;
+ size_t ShrinkSize;
+ size_t PrevSize;
+
ui64 Id;
-
- double Sum;
- double MinValue;
- double MaxValue;
-
+
+ double Sum;
+ double MinValue;
+ double MaxValue;
+
TVector<TWeightedValue> Bins;
-
- public:
+
+ public:
TBlockHistogram(EHistogramType type, TQualityFunction calcQuality,
size_t intervals, ui64 id = 0, size_t shrinkSize = DEFAULT_SHRINK_SIZE);
-
+
virtual ~TBlockHistogram() {
- }
-
+ }
+
virtual void Clear();
- virtual void Add(double value, double weight);
- virtual void Add(const THistoRec& histoRec);
-
+ virtual void Add(double value, double weight);
+ virtual void Add(const THistoRec& histoRec);
+
virtual void Merge(const THistogram& histo, double multiplier);
virtual void Merge(const TVector<THistogram>& histogramsToMerge);
virtual void Merge(TVector<IHistogramPtr> histogramsToMerge); // not implemented
virtual void Multiply(double factor);
- virtual void FromProto(const THistogram& histo);
- virtual void ToProto(THistogram& histo);
-
+ virtual void FromProto(const THistogram& histo);
+ virtual void ToProto(THistogram& histo);
+
virtual void SetId(ui64 id);
virtual ui64 GetId();
- virtual bool Empty();
- virtual double GetMinValue();
- virtual double GetMaxValue();
- virtual double GetSum();
-
- // methods below are not implemented
- virtual double GetSumInRange(double leftBound, double rightBound);
- virtual double GetSumAboveBound(double bound);
- virtual double GetSumBelowBound(double bound);
- virtual double CalcUpperBound(double sum);
- virtual double CalcLowerBound(double sum);
+ virtual bool Empty();
+ virtual double GetMinValue();
+ virtual double GetMaxValue();
+ virtual double GetSum();
+
+ // methods below are not implemented
+ virtual double GetSumInRange(double leftBound, double rightBound);
+ virtual double GetSumAboveBound(double bound);
+ 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);
-
- private:
- void SortBins();
+
+ private:
+ void SortBins();
void UniquifyBins();
- void CorrectShrinkSize();
-
- void SortAndShrink(size_t intervals, bool final = false);
+ void CorrectShrinkSize();
+
+ void SortAndShrink(size_t intervals, bool final = false);
- void SlowShrink(size_t intervals);
+ void SlowShrink(size_t intervals);
virtual void FastGreedyShrink(size_t intervals) = 0;
- };
-
+ };
+
/////////////////////////
// TBlockWeightHistogram
/////////////////////////