diff options
author | babenko <babenko@yandex-team.com> | 2023-10-18 13:10:41 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2023-10-18 14:04:23 +0300 |
commit | 33164cf11158c0b00c25e1e6ba78ccee0cbd807a (patch) | |
tree | 0f938c3fd82f40e4489c4fbd34fc9b8c68994bbe | |
parent | f11e41fedf342df30c8517b226ae793ec60ae4f9 (diff) | |
download | ydb-33164cf11158c0b00c25e1e6ba78ccee0cbd807a.tar.gz |
Y_ABORT_UNLESS -> YT_VERIFY within main YT C++ codebase
-rw-r--r-- | yt/yt/library/formats/protobuf.cpp | 4 | ||||
-rw-r--r-- | yt/yt/library/formats/protobuf_parser.cpp | 2 | ||||
-rw-r--r-- | yt/yt/library/formats/protobuf_writer.cpp | 2 | ||||
-rw-r--r-- | yt/yt/library/formats/skiff_writer.cpp | 2 | ||||
-rw-r--r-- | yt/yt/library/numeric/binary_search-inl.h | 29 | ||||
-rw-r--r-- | yt/yt/library/numeric/double_array.h | 10 | ||||
-rw-r--r-- | yt/yt/library/numeric/piecewise_linear_function-inl.h | 68 | ||||
-rw-r--r-- | yt/yt/library/numeric/ya.make | 1 |
8 files changed, 59 insertions, 59 deletions
diff --git a/yt/yt/library/formats/protobuf.cpp b/yt/yt/library/formats/protobuf.cpp index 4ed6d7f5d1..b154817dcb 100644 --- a/yt/yt/library/formats/protobuf.cpp +++ b/yt/yt/library/formats/protobuf.cpp @@ -573,7 +573,7 @@ public: [[nodiscard]] TGuard Enter(const Descriptor* descriptor) { if (ActiveVertices_.contains(descriptor)) { - Y_ABORT_UNLESS(!Stack_.empty()); + YT_VERIFY(!Stack_.empty()); THROW_ERROR_EXCEPTION("Cyclic reference found for protobuf messages. " "Consider removing %Qv flag somewhere on the cycle containing %Qv and %Qv", EWrapperFieldFlag_Enum_Name(EWrapperFieldFlag::SERIALIZATION_YT), @@ -622,7 +622,7 @@ private: const FieldDescriptor* fieldDescriptor, const TProtobufFieldOptions& fieldOptions) { - Y_ABORT_UNLESS(fieldDescriptor->is_map()); + YT_VERIFY(fieldDescriptor->is_map()); const auto* descriptor = fieldDescriptor->message_type(); switch (fieldOptions.MapMode) { case EProtobufMapMode::ListOfStructsLegacy: diff --git a/yt/yt/library/formats/protobuf_parser.cpp b/yt/yt/library/formats/protobuf_parser.cpp index d0504be438..5b3a575091 100644 --- a/yt/yt/library/formats/protobuf_parser.cpp +++ b/yt/yt/library/formats/protobuf_parser.cpp @@ -379,7 +379,7 @@ private: int embeddedChildIndex = childIndex; if (depth == 0 && childDescription.Type->ProtoType != EProtobufType::EmbeddedMessage) { auto maybeEmbeddedChildIndex = type->FieldNumberToEmbeddedChildIndex(fieldNumber); - Y_ABORT_UNLESS(maybeEmbeddedChildIndex); + YT_VERIFY(maybeEmbeddedChildIndex); embeddedChildIndex = *maybeEmbeddedChildIndex; } diff --git a/yt/yt/library/formats/protobuf_writer.cpp b/yt/yt/library/formats/protobuf_writer.cpp index 0a32808277..90be9baaba 100644 --- a/yt/yt/library/formats/protobuf_writer.cpp +++ b/yt/yt/library/formats/protobuf_writer.cpp @@ -699,7 +699,7 @@ public: }; while (parentEmbeddingIndex < std::ssize(embeddings)) { - Y_ABORT_UNLESS(embeddings[parentEmbeddingIndex].ParentEmbeddingIndex == TProtobufWriterEmbeddingDescription::InvalidIndex); + YT_VERIFY(embeddings[parentEmbeddingIndex].ParentEmbeddingIndex == TProtobufWriterEmbeddingDescription::InvalidIndex); parentEmbeddingIndex = EmitMessage(parentEmbeddingIndex); } diff --git a/yt/yt/library/formats/skiff_writer.cpp b/yt/yt/library/formats/skiff_writer.cpp index 0196f7890d..c231af595f 100644 --- a/yt/yt/library/formats/skiff_writer.cpp +++ b/yt/yt/library/formats/skiff_writer.cpp @@ -1068,7 +1068,7 @@ ISchemalessFormatWriterPtr CreateWriterForSkiff( auto copySchemas = schemas; if (config->OverrideIntermediateTableSchema) { - Y_ABORT_UNLESS(!schemas.empty()); + YT_VERIFY(!schemas.empty()); if (!IsTrivialIntermediateSchema(*schemas[0])) { THROW_ERROR_EXCEPTION("Cannot use \"override_intermediate_table_schema\" since input table #0 has nontrivial schema") << TErrorAttribute("schema", *schemas[0]); diff --git a/yt/yt/library/numeric/binary_search-inl.h b/yt/yt/library/numeric/binary_search-inl.h index 0190b7f8e5..32057683b4 100644 --- a/yt/yt/library/numeric/binary_search-inl.h +++ b/yt/yt/library/numeric/binary_search-inl.h @@ -4,10 +4,9 @@ #include "binary_search.h" #endif -namespace NYT { +#include <library/cpp/yt/assert/assert.h> -using std::uint32_t; -using std::uint64_t; +namespace NYT { //////////////////////////////////////////////////////////////////////////////// @@ -59,9 +58,9 @@ constexpr TInt IntegerLowerBound(TInt lo, TInt hi, TPredicate&& predicate) using TUInt = std::make_unsigned_t<TInt>; - Y_ABORT_UNLESS(lo <= hi); + YT_VERIFY(lo <= hi); - Y_ABORT_UNLESS(predicate(hi)); + YT_VERIFY(predicate(hi)); if (predicate(lo)) { return lo; } @@ -88,9 +87,9 @@ constexpr TInt IntegerInverseLowerBound(TInt lo, TInt hi, TPredicate&& predicate using TUInt = std::make_unsigned_t<TInt>; - Y_ABORT_UNLESS(lo <= hi); + YT_VERIFY(lo <= hi); - Y_ABORT_UNLESS(predicate(lo)); + YT_VERIFY(predicate(lo)); if (predicate(hi)) { return hi; } @@ -113,13 +112,13 @@ constexpr TInt IntegerInverseLowerBound(TInt lo, TInt hi, TPredicate&& predicate template <class TPredicate> double FloatingPointLowerBound(double lo, double hi, TPredicate&& predicate) { - Y_ABORT_UNLESS(!std::isnan(lo)); - Y_ABORT_UNLESS(!std::isnan(hi)); - Y_ABORT_UNLESS(lo <= hi); + YT_VERIFY(!std::isnan(lo)); + YT_VERIFY(!std::isnan(hi)); + YT_VERIFY(lo <= hi); // NB(antonkikh): Note that this handles the case when |hi == -0.0| and |lo == 0.0|. if (lo == hi) { - Y_ABORT_UNLESS(predicate(hi)); + YT_VERIFY(predicate(hi)); return hi; } @@ -133,13 +132,13 @@ double FloatingPointLowerBound(double lo, double hi, TPredicate&& predicate) template <class TPredicate> double FloatingPointInverseLowerBound(double lo, double hi, TPredicate&& predicate) { - Y_ABORT_UNLESS(!std::isnan(lo)); - Y_ABORT_UNLESS(!std::isnan(hi)); - Y_ABORT_UNLESS(lo <= hi); + YT_VERIFY(!std::isnan(lo)); + YT_VERIFY(!std::isnan(hi)); + YT_VERIFY(lo <= hi); // NB(antonkikh): Note that this handles the case when |hi == -0.0| and |lo == 0.0|. if (lo == hi) { - Y_ABORT_UNLESS(predicate(lo)); + YT_VERIFY(predicate(lo)); return lo; } diff --git a/yt/yt/library/numeric/double_array.h b/yt/yt/library/numeric/double_array.h index d8e81f9850..1416851707 100644 --- a/yt/yt/library/numeric/double_array.h +++ b/yt/yt/library/numeric/double_array.h @@ -390,16 +390,16 @@ constexpr TDerived Div( // // Example of usage: // TDoubleArray<4> vec1 = {1, 2, 3, 4}; -// Y_ABORT_UNLESS(vec1[3] == 4); -// Y_ABORT_UNLESS(TDoubleArray<4>::All(vec1, [] (double x) { return x > 0; })); -// Y_ABORT_UNLESS(MinComponent(vec1) == 1); +// YT_VERIFY(vec1[3] == 4); +// YT_VERIFY(TDoubleArray<4>::All(vec1, [] (double x) { return x > 0; })); +// YT_VERIFY(MinComponent(vec1) == 1); // // TDoubleArray<4> vec2 = {4, 3, 2, 1}; -// Y_ABORT_UNLESS(vec1 + vec2 == TDoubleArray<4>::FromDouble(5)); +// YT_VERIFY(vec1 + vec2 == TDoubleArray<4>::FromDouble(5)); // // // |vec1 * vec1| wouldn't work because multiplication is not defined for mathematical vectors. // auto vec1Square = TDoubleArray<4>::Apply(vec1, [] (double x) { return x * x; }); -// Y_ABORT_UNLESS(TDoubleArray<4>::All(vec1, vec1Square, [] (double x, double y) { return y == x * x; })); +// YT_VERIFY(TDoubleArray<4>::All(vec1, vec1Square, [] (double x, double y) { return y == x * x; })); template <size_t DimCnt> class TDoubleArray final : public TDoubleArrayBase<DimCnt, TDoubleArray<DimCnt>> { diff --git a/yt/yt/library/numeric/piecewise_linear_function-inl.h b/yt/yt/library/numeric/piecewise_linear_function-inl.h index 35133278ed..dd50fbe60a 100644 --- a/yt/yt/library/numeric/piecewise_linear_function-inl.h +++ b/yt/yt/library/numeric/piecewise_linear_function-inl.h @@ -15,7 +15,7 @@ TPiecewiseSegment<TValue>::TPiecewiseSegment(std::pair<double, TValue> leftPoint , RightBound_(rightPoint.first) , RightValue_(rightPoint.second) { - Y_ABORT_UNLESS(LeftBound_ <= RightBound_); + YT_VERIFY(LeftBound_ <= RightBound_); } template <class TValue> @@ -57,21 +57,21 @@ bool TPiecewiseSegment<TValue>::IsDefinedOn(double left, double right) const template <class TValue> TValue TPiecewiseSegment<TValue>::LeftLimitAt(double x) const { - Y_ABORT_UNLESS(IsDefinedAt(x)); + YT_VERIFY(IsDefinedAt(x)); return LeftRightLimitAt(x).first; } template <class TValue> TValue TPiecewiseSegment<TValue>::RightLimitAt(double x) const { - Y_ABORT_UNLESS(IsDefinedAt(x)); + YT_VERIFY(IsDefinedAt(x)); return LeftRightLimitAt(x).second; } template <class TValue> std::pair<TValue, TValue> TPiecewiseSegment<TValue>::LeftRightLimitAt(double x) const { - Y_ABORT_UNLESS(IsDefinedAt(x)); + YT_VERIFY(IsDefinedAt(x)); if (RightBound() == LeftBound()) { return {LeftValue_, RightValue_}; } else { @@ -83,7 +83,7 @@ std::pair<TValue, TValue> TPiecewiseSegment<TValue>::LeftRightLimitAt(double x) template <class TValue> TValue TPiecewiseSegment<TValue>::ValueAt(double x) const { - Y_ABORT_UNLESS(IsDefinedAt(x)); + YT_VERIFY(IsDefinedAt(x)); // NB: We currently assume all functions to be left-continuous. return LeftLimitAt(x); } @@ -221,8 +221,8 @@ void PushSegmentImpl(std::vector<TPiecewiseSegment<TValue>>* vec, TPiecewiseSegm { if (!vec->empty()) { // NB: Strict equality is required in both cases. - Y_ABORT_UNLESS(vec->back().RightBound() == segment.LeftBound()); - Y_ABORT_UNLESS(vec->back().RightValue() == segment.LeftValue()); + YT_VERIFY(vec->back().RightBound() == segment.LeftBound()); + YT_VERIFY(vec->back().RightValue() == segment.LeftValue()); // Try to merge two segments. const auto& leftSegment = vec->back(); @@ -239,12 +239,12 @@ void PushSegmentImpl(std::vector<TPiecewiseSegment<TValue>>* vec, TPiecewiseSegm return; } if (leftSegment.IsVertical() && rightSegment.IsVertical()) { - Y_ABORT_UNLESS(mergedSegment.IsVertical()); + YT_VERIFY(mergedSegment.IsVertical()); vec->back() = mergedSegment; return; } if (leftSegment.IsHorizontal() && rightSegment.IsHorizontal()) { - Y_ABORT_UNLESS(mergedSegment.IsHorizontal()); + YT_VERIFY(mergedSegment.IsHorizontal()); vec->back() = mergedSegment; return; } @@ -260,7 +260,7 @@ TPiecewiseLinearFunction<TValue> PointwiseMin( { double resultLeftBound = std::max(lhs.LeftFunctionBound(), rhs.LeftFunctionBound()); double resultRightBound = std::min(lhs.RightFunctionBound(), rhs.RightFunctionBound()); - Y_ABORT_UNLESS(resultLeftBound <= resultRightBound); + YT_VERIFY(resultLeftBound <= resultRightBound); auto sampleResult = [ lhsTraverser = lhs.GetLeftToRightTraverser(), @@ -293,7 +293,7 @@ TPiecewiseLinearFunction<TValue> PointwiseMin( for (int i = 1; i < criticalPointsInitialSize; i++) { double leftBound = criticalPoints[i - 1]; double rightBound = criticalPoints[i]; - Y_ABORT_UNLESS(leftBound < rightBound); + YT_VERIFY(leftBound < rightBound); // NB: Cannot use structure bindings here because it is not compatible with lambda capturing until C++20. auto pair = MinMaxBy( @@ -303,8 +303,8 @@ TPiecewiseLinearFunction<TValue> PointwiseMin( auto segmentLo = pair.first; auto segmentHi = pair.second; - Y_ABORT_UNLESS(segmentLo.IsDefinedOn(leftBound, rightBound)); - Y_ABORT_UNLESS(segmentHi.IsDefinedOn(leftBound, rightBound)); + YT_VERIFY(segmentLo.IsDefinedOn(leftBound, rightBound)); + YT_VERIFY(segmentHi.IsDefinedOn(leftBound, rightBound)); if (segmentLo.ValueAt(leftBound) < segmentHi.ValueAt(leftBound) && segmentLo.ValueAt(rightBound) > segmentHi.ValueAt(rightBound)) @@ -328,7 +328,7 @@ TPiecewiseLinearFunction<TValue> PointwiseMin( template <class TValue> TPiecewiseLinearFunction<TValue> PointwiseMin(const std::vector<TPiecewiseLinearFunction<TValue>>& funcs) { - Y_ABORT_UNLESS(!funcs.empty()); + YT_VERIFY(!funcs.empty()); return std::accumulate( begin(funcs) + 1, end(funcs), @@ -352,8 +352,8 @@ template <class TValue> void TPiecewiseLinearFunctionBuilder<TValue>::PushSegment(const TSegment& segment) { if (RightPoint_) { - Y_ABORT_UNLESS(RightPoint_->first == segment.LeftBound()); - Y_ABORT_UNLESS(RightPoint_->second == segment.LeftValue()); + YT_VERIFY(RightPoint_->first == segment.LeftBound()); + YT_VERIFY(RightPoint_->second == segment.LeftValue()); } PushSegmentImpl(&Segments_, segment); RightPoint_ = TPoint(segment.RightBound(), segment.RightValue()); @@ -387,15 +387,15 @@ TPiecewiseLinearFunction<TValue> TPiecewiseLinearFunction<TValue>::Create( static_assert(std::is_same_v<decltype(sampleFunction(1.0L)), std::pair<TValue, TValue>>); ClearAndSortCriticalPoints(&criticalPoints, leftBound, rightBound); - Y_ABORT_UNLESS(!criticalPoints.empty()); + YT_VERIFY(!criticalPoints.empty()); if (criticalPoints.front() != leftBound) { throw yexception() << "Left bound of the function must be its first critical point (CriticalPoints: [" << NDetail::ToString(criticalPoints) << "], LeftBound: " << leftBound << ")"; } - Y_ABORT_UNLESS(criticalPoints.front() == leftBound); - Y_ABORT_UNLESS(criticalPoints.back() == rightBound); + YT_VERIFY(criticalPoints.front() == leftBound); + YT_VERIFY(criticalPoints.back() == rightBound); TBuilder builder; @@ -418,7 +418,7 @@ template <class TValue> TPiecewiseLinearFunction<TValue>::TPiecewiseLinearFunction(std::vector<TPiecewiseSegment<TValue>> segments) : Segments_(std::move(segments)) { - Y_ABORT_UNLESS(!Segments_.empty()); + YT_VERIFY(!Segments_.empty()); } template <class TValue> @@ -494,7 +494,7 @@ TValue TPiecewiseLinearFunction<TValue>::LeftFunctionValue() const template <class TValue> TValue TPiecewiseLinearFunction<TValue>::RightFunctionValue() const { - Y_ABORT_UNLESS(!Segments_.back().IsVertical()); + YT_VERIFY(!Segments_.back().IsVertical()); return Segments_.back().RightValue(); } @@ -569,7 +569,7 @@ const TPiecewiseSegment<TValue>& TPiecewiseLinearFunction<TValue>::RightSegmentA end(Segments_), /* value */ x, [] (const auto& segment) { return segment.LeftBound(); }); - Y_ABORT_UNLESS(it != begin(Segments_)); + YT_VERIFY(it != begin(Segments_)); // We need the last segment with LeftBound() <= x. --it; @@ -648,7 +648,7 @@ TPiecewiseLinearFunction<TValue>& TPiecewiseLinearFunction<TValue>::TrimLeftInpl Segments_.front() = TSegment({argument, value}, {argument, value}); } - Y_ABORT_UNLESS(!Segments_.front().IsVertical()); + YT_VERIFY(!Segments_.front().IsVertical()); } return *this; @@ -682,7 +682,7 @@ TPiecewiseLinearFunction<TValue>& TPiecewiseLinearFunction<TValue>::TrimRightInp Segments_.back() = TSegment({argument, value}, {argument, value}); } - Y_ABORT_UNLESS(!Segments_.back().IsVertical()); + YT_VERIFY(!Segments_.back().IsVertical()); } return *this; @@ -763,9 +763,9 @@ TPiecewiseLinearFunction<TValue> TPiecewiseLinearFunction<TValue>::Narrow( double newLeftBound, double newRightBound) const { - Y_ABORT_UNLESS(IsDefinedAt(newLeftBound)); - Y_ABORT_UNLESS(IsDefinedAt(newRightBound)); - Y_ABORT_UNLESS(newLeftBound <= newRightBound); + YT_VERIFY(IsDefinedAt(newLeftBound)); + YT_VERIFY(IsDefinedAt(newRightBound)); + YT_VERIFY(newLeftBound <= newRightBound); return *this + Constant(newLeftBound, newRightBound, TValue{}); } @@ -789,7 +789,7 @@ TPiecewiseLinearFunction<TValue> TPiecewiseLinearFunction<TValue>::Extend( double newRightBound, const TValue& newRightValue) const { - Y_ABORT_UNLESS(newLeftBound <= LeftFunctionBound()); + YT_VERIFY(newLeftBound <= LeftFunctionBound()); TBuilder builder; @@ -870,7 +870,7 @@ template <class TValue> TPiecewiseLinearFunction<TValue> TPiecewiseLinearFunction<TValue>::Sum( const std::vector<TPiecewiseLinearFunction<TValue>>& funcs) { - Y_ABORT_UNLESS(!funcs.empty()); + YT_VERIFY(!funcs.empty()); double resultLeftBound = std::numeric_limits<double>::lowest(); double resultRightBound = std::numeric_limits<double>::max(); @@ -878,7 +878,7 @@ TPiecewiseLinearFunction<TValue> TPiecewiseLinearFunction<TValue>::Sum( resultLeftBound = std::max(resultLeftBound, func.LeftFunctionBound()); resultRightBound = std::min(resultRightBound, func.RightFunctionBound()); } - Y_ABORT_UNLESS(resultLeftBound <= resultRightBound); + YT_VERIFY(resultLeftBound <= resultRightBound); std::vector<double> criticalPoints; for (const auto& func : funcs) { @@ -923,8 +923,8 @@ TPiecewiseLinearFunction<TValue> TPiecewiseLinearFunction<TValue>::Compose(const if (!other.IsNondecreasing()) { throw yexception() << "Composition is only supported for non-decreasing functions"; } - Y_ABORT_UNLESS(IsDefinedAt(other.LeftLimitAt(other.LeftFunctionBound()))); - Y_ABORT_UNLESS(IsDefinedAt(other.RightLimitAt(other.RightFunctionBound()))); + YT_VERIFY(IsDefinedAt(other.LeftLimitAt(other.LeftFunctionBound()))); + YT_VERIFY(IsDefinedAt(other.RightLimitAt(other.RightFunctionBound()))); // Prepare critical points with the expected values of the rhs function at these points. std::vector<std::pair<double, double>> criticalPoints; @@ -986,8 +986,8 @@ TPiecewiseLinearFunction<TValue> TPiecewiseLinearFunction<TValue>::Compose(const TSelf result = builder.Finish().Trim(); - Y_ABORT_UNLESS(result.LeftFunctionBound() == other.LeftFunctionBound()); - Y_ABORT_UNLESS(result.RightFunctionBound() == other.RightFunctionBound()); + YT_VERIFY(result.LeftFunctionBound() == other.LeftFunctionBound()); + YT_VERIFY(result.RightFunctionBound() == other.RightFunctionBound()); return result; } diff --git a/yt/yt/library/numeric/ya.make b/yt/yt/library/numeric/ya.make index b95d314c0b..39fc663491 100644 --- a/yt/yt/library/numeric/ya.make +++ b/yt/yt/library/numeric/ya.make @@ -17,6 +17,7 @@ CHECK_DEPENDENT_DIRS( contrib library util + library/cpp/yt/assert library/cpp/yt/small_containers ) |