aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/histogram
diff options
context:
space:
mode:
authorvictor-k <victor-k@yandex-team.ru>2022-02-10 16:50:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:38 +0300
commit17cbaf6d2b820cd304e92faa6ac2e6426605cae8 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/histogram
parentf632afcab870d2327aaa8388ceeb7aeb2bb6a1c1 (diff)
downloadydb-17cbaf6d2b820cd304e92faa6ac2e6426605cae8.tar.gz
Restoring authorship annotation for <victor-k@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/histogram')
-rw-r--r--library/cpp/histogram/adaptive/adaptive_histogram.cpp50
-rw-r--r--library/cpp/histogram/adaptive/adaptive_histogram.h14
-rw-r--r--library/cpp/histogram/adaptive/auto_histogram.h28
-rw-r--r--library/cpp/histogram/adaptive/block_histogram.cpp40
-rw-r--r--library/cpp/histogram/adaptive/block_histogram.h16
-rw-r--r--library/cpp/histogram/adaptive/fixed_bin_histogram.cpp60
-rw-r--r--library/cpp/histogram/adaptive/fixed_bin_histogram.h16
-rw-r--r--library/cpp/histogram/adaptive/histogram.h10
-rw-r--r--library/cpp/histogram/adaptive/multi_histogram.h4
9 files changed, 119 insertions, 119 deletions
diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.cpp b/library/cpp/histogram/adaptive/adaptive_histogram.cpp
index b1e7e85aed..cbfc494021 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 0737a62b95..fa8f48433f 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 abd4c17603..9fdf0b9abe 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 779d90496c..6586d13ff6 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 3588185fef..266bb2f2b2 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 e8dd6e6103..558aba9e2d 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 7404bddd9a..bd380bd94a 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 fb8d0984b3..360fd9a693 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 54ae1463e5..41caac5ba6 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;