diff options
author | ilnurkh <ilnurkh@yandex-team.com> | 2023-10-09 23:39:40 +0300 |
---|---|---|
committer | ilnurkh <ilnurkh@yandex-team.com> | 2023-10-09 23:57:14 +0300 |
commit | e601ca03f859335d57ecff2e5aa6af234b6052ed (patch) | |
tree | de519a847e58a1b3993fcbfe05ff44cc946a3e24 /library/cpp/histogram/adaptive | |
parent | bbf2b6878af3854815a2c0ecb07a687071787639 (diff) | |
download | ydb-e601ca03f859335d57ecff2e5aa6af234b6052ed.tar.gz |
Y_VERIFY->Y_ABORT_UNLESS at ^l
https://clubs.at.yandex-team.ru/arcadia/29404
Diffstat (limited to 'library/cpp/histogram/adaptive')
-rw-r--r-- | library/cpp/histogram/adaptive/adaptive_histogram.cpp | 32 | ||||
-rw-r--r-- | library/cpp/histogram/adaptive/block_histogram.cpp | 12 | ||||
-rw-r--r-- | library/cpp/histogram/adaptive/fixed_bin_histogram.cpp | 2 |
3 files changed, 23 insertions, 23 deletions
diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.cpp b/library/cpp/histogram/adaptive/adaptive_histogram.cpp index 3e91ed1131..4bc4f63cda 100644 --- a/library/cpp/histogram/adaptive/adaptive_histogram.cpp +++ b/library/cpp/histogram/adaptive/adaptive_histogram.cpp @@ -82,7 +82,7 @@ namespace NKiwiAggr { histo.GetType() == HT_ADAPTIVE_WARD_HISTOGRAM || histo.GetType() == HT_ADAPTIVE_HISTOGRAM) { - Y_VERIFY(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); + Y_ABORT_UNLESS(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); for (size_t j = 0; j < histo.FreqSize(); ++j) { double value = histo.GetPosition(j); double weight = histo.GetFreq(j); @@ -182,7 +182,7 @@ namespace NKiwiAggr { } void TAdaptiveHistogram::FromProto(const THistogram& histo) { - Y_VERIFY(histo.HasType(), "Attempt to parse TAdaptiveHistogram from THistogram protobuf with no Type field set"); + Y_ABORT_UNLESS(histo.HasType(), "Attempt to parse TAdaptiveHistogram from THistogram protobuf with no Type field set"); ; switch (histo.GetType()) { // check that histogram type could be deduced case HT_ADAPTIVE_DISTANCE_HISTOGRAM: @@ -352,7 +352,7 @@ namespace NKiwiAggr { } double TAdaptiveHistogram::CalcUpperBound(double sum) { - Y_VERIFY(sum >= 0, "Sum must be >= 0"); + Y_ABORT_UNLESS(sum >= 0, "Sum must be >= 0"); if (sum == 0.0) { return MinValue; } @@ -393,7 +393,7 @@ namespace NKiwiAggr { } double TAdaptiveHistogram::CalcLowerBound(double sum) { - Y_VERIFY(sum >= 0, "Sum must be >= 0"); + Y_ABORT_UNLESS(sum >= 0, "Sum must be >= 0"); if (sum == 0.0) { return MaxValue; } @@ -511,13 +511,13 @@ namespace NKiwiAggr { ++rightBin; TWeightedValue newBin(value, weight + currentBin->second); if (rightBin != Bins.end()) { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) == 1, "Erase failed"); + Y_ABORT_UNLESS(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) == 1, "Erase failed"); BinsByQuality.insert(CalcQuality(newBin, *rightBin)); } if (currentBin != Bins.begin()) { TPairSet::iterator leftBin = currentBin; --leftBin; - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) == 1, "Erase failed"); + Y_ABORT_UNLESS(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) == 1, "Erase failed"); BinsByQuality.insert(CalcQuality(*leftBin, newBin)); } Bins.erase(currentBin); @@ -532,7 +532,7 @@ namespace NKiwiAggr { if (rightBin == Bins.end()) { BinsByQuality.insert(CalcQuality(*leftBin, weightedValue)); } else { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *rightBin)) == 1, "Erase failed"); + Y_ABORT_UNLESS(BinsByQuality.erase(CalcQuality(*leftBin, *rightBin)) == 1, "Erase failed"); BinsByQuality.insert(CalcQuality(*leftBin, weightedValue)); BinsByQuality.insert(CalcQuality(weightedValue, *rightBin)); } @@ -545,20 +545,20 @@ namespace NKiwiAggr { void TAdaptiveHistogram::Erase(double value) { TPairSet::iterator currentBin = Bins.lower_bound(TWeightedValue(value, -1.0)); - Y_VERIFY(currentBin != Bins.end() && currentBin->first == value, "Can't find bin that should be erased"); + Y_ABORT_UNLESS(currentBin != Bins.end() && currentBin->first == value, "Can't find bin that should be erased"); TPairSet::iterator rightBin = currentBin; ++rightBin; if (currentBin == Bins.begin()) { - Y_VERIFY(rightBin != Bins.end(), "No right bin for the first bin"); - Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); + Y_ABORT_UNLESS(rightBin != Bins.end(), "No right bin for the first bin"); + Y_ABORT_UNLESS(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); } else { TPairSet::iterator leftBin = currentBin; --leftBin; if (rightBin == Bins.end()) { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); + Y_ABORT_UNLESS(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); } else { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); - Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); + Y_ABORT_UNLESS(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); + Y_ABORT_UNLESS(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); BinsByQuality.insert(CalcQuality(*leftBin, *rightBin)); } } @@ -567,12 +567,12 @@ namespace NKiwiAggr { void TAdaptiveHistogram::Shrink() { TPairSet::iterator worstBin = BinsByQuality.begin(); - Y_VERIFY(worstBin != BinsByQuality.end(), "No right bin for the first bin"); + Y_ABORT_UNLESS(worstBin != BinsByQuality.end(), "No right bin for the first bin"); TPairSet::iterator leftBin = Bins.lower_bound(TWeightedValue(worstBin->second, -1.0)); - Y_VERIFY(leftBin != Bins.end() && leftBin->first == worstBin->second, "Can't find worst bin"); + Y_ABORT_UNLESS(leftBin != Bins.end() && leftBin->first == worstBin->second, "Can't find worst bin"); TPairSet::iterator rightBin = leftBin; ++rightBin; - Y_VERIFY(rightBin != Bins.end(), "Can't find right bin"); + Y_ABORT_UNLESS(rightBin != Bins.end(), "Can't find right bin"); TWeightedValue newBin((leftBin->first * leftBin->second + rightBin->first * rightBin->second) / (leftBin->second + rightBin->second), leftBin->second + rightBin->second); if (Bins.size() > 2) { diff --git a/library/cpp/histogram/adaptive/block_histogram.cpp b/library/cpp/histogram/adaptive/block_histogram.cpp index 6586d13ff6..55337488ac 100644 --- a/library/cpp/histogram/adaptive/block_histogram.cpp +++ b/library/cpp/histogram/adaptive/block_histogram.cpp @@ -149,7 +149,7 @@ namespace NKiwiAggr { histo.GetType() == HT_ADAPTIVE_WARD_HISTOGRAM || histo.GetType() == HT_ADAPTIVE_HISTOGRAM) { - Y_VERIFY(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); + Y_ABORT_UNLESS(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); for (size_t j = 0; j < histo.FreqSize(); ++j) { double value = histo.GetPosition(j); double weight = histo.GetFreq(j); @@ -204,7 +204,7 @@ namespace NKiwiAggr { } void TBlockHistogram::FromProto(const THistogram& histo) { - Y_VERIFY(histo.HasType(), "Attempt to parse TBlockHistogram from THistogram protobuf with no Type field set"); + Y_ABORT_UNLESS(histo.HasType(), "Attempt to parse TBlockHistogram from THistogram protobuf with no Type field set"); ; switch (histo.GetType()) { // check that histogram type is correct case HT_ADAPTIVE_DISTANCE_HISTOGRAM: @@ -286,7 +286,7 @@ namespace NKiwiAggr { } void TBlockHistogram::SortAndShrink(size_t intervals, bool final) { - Y_VERIFY(intervals > 0); + Y_ABORT_UNLESS(intervals > 0); if (Bins.size() <= intervals) { return; @@ -382,7 +382,7 @@ namespace NKiwiAggr { ui32 a = (ui32)(bins[b].Prev() - bins); ui32 c = (ui32)(bins[b].Next() - bins); ui32 d = (ui32)(bins[b].Next()->Next() - bins); - Y_VERIFY(Bins[c].second != -1); + Y_ABORT_UNLESS(Bins[c].second != -1); double mass = Bins[b].second + Bins[c].second; Bins[c].first = (Bins[b].first * Bins[b].second + Bins[c].first * Bins[c].second) / mass; @@ -411,7 +411,7 @@ namespace NKiwiAggr { Bins.resize(pos); PrevSize = pos; - Y_VERIFY(pos == intervals); + Y_ABORT_UNLESS(pos == intervals); } double TBlockHistogram::GetSumInRange(double leftBound, double rightBound) { @@ -528,7 +528,7 @@ namespace NKiwiAggr { } void TBlockWardHistogram::FastGreedyShrink(size_t intervals) { - Y_VERIFY(intervals > 0); + Y_ABORT_UNLESS(intervals > 0); if (Bins.size() <= intervals) { return; diff --git a/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp b/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp index 558aba9e2d..a6bcd3a517 100644 --- a/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp +++ b/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp @@ -512,7 +512,7 @@ namespace NKiwiAggr { } void TFixedBinHistogram::Shrink(double newReferencePoint, double newMaxValue) { - Y_VERIFY(newReferencePoint < newMaxValue, "Invalid Shrink()"); + Y_ABORT_UNLESS(newReferencePoint < newMaxValue, "Invalid Shrink()"); memset(&(ReserveFreqs[0]), 0, ReserveFreqs.size() * sizeof(double)); double newBinRange = CalcBinRange(newReferencePoint, newMaxValue); |