diff options
author | ilnurkh <ilnurkh@yandex-team.com> | 2023-10-09 20:25:13 +0300 |
---|---|---|
committer | ilnurkh <ilnurkh@yandex-team.com> | 2023-10-09 20:46:53 +0300 |
commit | 6ef6895772bc473a21252db8a2a9f4c1b179841c (patch) | |
tree | d02a2d6e7014703f915b4042d8648196847186a6 | |
parent | c9bb61f5c70bf0d4194b5d6285afc1e5447130e4 (diff) | |
download | ydb-6ef6895772bc473a21252db8a2a9f4c1b179841c.tar.gz |
Y_VERIFY->Y_ABORT_UNLESS at ^yt
https://clubs.at.yandex-team.ru/arcadia/29404
33 files changed, 145 insertions, 145 deletions
diff --git a/yt/cpp/mapreduce/client/client.cpp b/yt/cpp/mapreduce/client/client.cpp index a395174f79..42c96fcde2 100644 --- a/yt/cpp/mapreduce/client/client.cpp +++ b/yt/cpp/mapreduce/client/client.cpp @@ -1102,7 +1102,7 @@ TAuthorizationInfo TClient::WhoAmI() NJson::TJsonValue jsonValue; bool ok = NJson::ReadJsonTree(requestResult.Response, &jsonValue, /* throwOnError = */ true); - Y_VERIFY(ok); + Y_ABORT_UNLESS(ok); result.Login = jsonValue["login"].GetString(); result.Realm = jsonValue["realm"].GetString(); return result; diff --git a/yt/cpp/mapreduce/client/client_reader.cpp b/yt/cpp/mapreduce/client/client_reader.cpp index 5b4369ecbf..f1c1231220 100644 --- a/yt/cpp/mapreduce/client/client_reader.cpp +++ b/yt/cpp/mapreduce/client/client_reader.cpp @@ -54,7 +54,7 @@ TClientReader::TClientReader( , ReadTransaction_(nullptr) { if (options.CreateTransaction_) { - Y_VERIFY(transactionPinger, "Internal error: transactionPinger is null"); + Y_ABORT_UNLESS(transactionPinger, "Internal error: transactionPinger is null"); ReadTransaction_ = MakeHolder<TPingableTransaction>( ClientRetryPolicy_, Context_, diff --git a/yt/cpp/mapreduce/client/file_reader.cpp b/yt/cpp/mapreduce/client/file_reader.cpp index 35b2133651..5454b9b11f 100644 --- a/yt/cpp/mapreduce/client/file_reader.cpp +++ b/yt/cpp/mapreduce/client/file_reader.cpp @@ -153,7 +153,7 @@ NHttpClient::IHttpResponsePtr TFileReader::Request(const TClientContext& context header.SetOutputFormat(TMaybe<TFormat>()); // Binary format if (EndOffset_) { - Y_VERIFY(*EndOffset_ >= currentOffset); + Y_ABORT_UNLESS(*EndOffset_ >= currentOffset); FileReaderOptions_.Length(*EndOffset_ - currentOffset); } FileReaderOptions_.Offset(currentOffset); diff --git a/yt/cpp/mapreduce/client/file_writer.cpp b/yt/cpp/mapreduce/client/file_writer.cpp index daf6461edd..6e6553b88c 100644 --- a/yt/cpp/mapreduce/client/file_writer.cpp +++ b/yt/cpp/mapreduce/client/file_writer.cpp @@ -41,7 +41,7 @@ void TFileWriter::DoWrite(const void* buf, size_t len) // and server produced one chunk of desired size and one small chunk. while (len > 0) { const auto retryBlockRemainingSize = RetryfulWriter_.GetRetryBlockRemainingSize(); - Y_VERIFY(retryBlockRemainingSize > 0); + Y_ABORT_UNLESS(retryBlockRemainingSize > 0); const auto firstWriteLen = Min(len, retryBlockRemainingSize); RetryfulWriter_.Write(buf, firstWriteLen); RetryfulWriter_.NotifyRowEnd(); diff --git a/yt/cpp/mapreduce/client/format_hints.cpp b/yt/cpp/mapreduce/client/format_hints.cpp index 1f6eb173ad..0c0121e7a5 100644 --- a/yt/cpp/mapreduce/client/format_hints.cpp +++ b/yt/cpp/mapreduce/client/format_hints.cpp @@ -34,7 +34,7 @@ static void ApplyEnableTypeConversion(TFormat* format, const TFormatHints& forma template <> void ApplyFormatHints<TNode>(TFormat* format, const TMaybe<TFormatHints>& formatHints) { - Y_VERIFY(format); + Y_ABORT_UNLESS(format); if (!formatHints) { return; } @@ -60,7 +60,7 @@ void ApplyFormatHints<TNode>(TFormat* format, const TMaybe<TFormatHints>& format template <> void ApplyFormatHints<TYaMRRow>(TFormat* format, const TMaybe<TFormatHints>& formatHints) { - Y_VERIFY(format); + Y_ABORT_UNLESS(format); if (!formatHints) { return; } @@ -71,7 +71,7 @@ void ApplyFormatHints<TYaMRRow>(TFormat* format, const TMaybe<TFormatHints>& for template <> void ApplyFormatHints<::google::protobuf::Message>(TFormat* format, const TMaybe<TFormatHints>& formatHints) { - Y_VERIFY(format); + Y_ABORT_UNLESS(format); if (!formatHints) { return; } diff --git a/yt/cpp/mapreduce/client/operation.cpp b/yt/cpp/mapreduce/client/operation.cpp index dfe7ecd223..855e6e834c 100644 --- a/yt/cpp/mapreduce/client/operation.cpp +++ b/yt/cpp/mapreduce/client/operation.cpp @@ -240,7 +240,7 @@ TStructuredJobTableList ApplyProtobufColumnFilters( continue; } auto& table = newTableList[tableIndex]; - Y_VERIFY(table.RichYPath); + Y_ABORT_UNLESS(table.RichYPath); if (table.RichYPath->Columns_) { continue; } @@ -326,7 +326,7 @@ TSimpleOperationIo CreateSimpleOperationIo( &outputs, hints); - Y_VERIFY(outputs.size() == outputSchemas.size()); + Y_ABORT_UNLESS(outputs.size() == outputSchemas.size()); for (int i = 0; i < static_cast<int>(outputs.size()); ++i) { if (!outputs[i].Schema_ && !outputSchemas[i].Columns().empty()) { outputs[i].Schema_ = outputSchemas[i]; @@ -556,7 +556,7 @@ EOperationBriefState CheckOperation( TGetOperationOptions().AttributeFilter(TOperationAttributeFilter() .Add(EOperationAttribute::State) .Add(EOperationAttribute::Result))); - Y_VERIFY(attributes.BriefState, + Y_ABORT_UNLESS(attributes.BriefState, "get_operation for operation %s has not returned \"state\" field", GetGuidAsString(operationId).Data()); if (*attributes.BriefState == EOperationBriefState::Completed) { @@ -573,7 +573,7 @@ EOperationBriefState CheckOperation( operationId, TGetFailedJobInfoOptions()); - Y_VERIFY(attributes.Result && attributes.Result->Error); + Y_ABORT_UNLESS(attributes.Result && attributes.Result->Error); ythrow TOperationFailedError( *attributes.BriefState == EOperationBriefState::Aborted ? TOperationFailedError::Aborted @@ -1624,7 +1624,7 @@ void ExecuteMapReduce( operationIo.MapperInputFormat = inputFormat; operationIo.MapperOutputFormat = outputFormat; - Y_VERIFY(mapperInferenceResult.size() >= 1); + Y_ABORT_UNLESS(mapperInferenceResult.size() >= 1); currentInferenceResult = TVector<TTableSchema>{mapperInferenceResult[0]}; // The first output as it corresponds to the intermediate data. TVector<TTableSchema> additionalOutputsInferenceResult(mapperInferenceResult.begin() + 1, mapperInferenceResult.end()); @@ -2051,7 +2051,7 @@ void ExecuteVanilla( preparer->GetPreparationId()); auto addTask = [&](TFluentMap fluent, const TVanillaTask& task) { - Y_VERIFY(task.Job_.Get()); + Y_ABORT_UNLESS(task.Job_.Get()); if (std::holds_alternative<TVoidStructuredRowStream>(task.Job_->GetOutputRowStreamDescription())) { Y_ENSURE_EX(task.Outputs_.empty(), TApiUsageError() << "Vanilla task with void IVanillaJob doesn't expect output tables"); @@ -2268,7 +2268,7 @@ public: OperationImpl_->AnalyzeUnrecognizedSpec(*attributes.UnrecognizedSpec); UnrecognizedSpecAnalyzed_ = true; } - Y_VERIFY(attributes.BriefState, + Y_ABORT_UNLESS(attributes.BriefState, "get_operation for operation %s has not returned \"state\" field", GetGuidAsString(OperationImpl_->GetId()).Data()); if (*attributes.BriefState != EOperationBriefState::InProgress) { @@ -2315,7 +2315,7 @@ TString TOperation::TOperationImpl::GetWebInterfaceUrl() const void TOperation::TOperationImpl::OnPrepared() { - Y_VERIFY(!PreparedPromise_.HasException() && !PreparedPromise_.HasValue()); + Y_ABORT_UNLESS(!PreparedPromise_.HasException() && !PreparedPromise_.HasValue()); PreparedPromise_.SetValue(); } @@ -2361,7 +2361,7 @@ bool TOperation::TOperationImpl::IsStarted() const { void TOperation::TOperationImpl::OnPreparationException(std::exception_ptr e) { - Y_VERIFY(!PreparedPromise_.HasValue() && !PreparedPromise_.HasException()); + Y_ABORT_UNLESS(!PreparedPromise_.HasValue() && !PreparedPromise_.HasException()); PreparedPromise_.SetException(e); } @@ -2437,7 +2437,7 @@ EOperationBriefState TOperation::TOperationImpl::GetBriefState() ValidateOperationStarted(); EOperationBriefState result = EOperationBriefState::InProgress; UpdateAttributesAndCall(false, [&] (const TOperationAttributes& attributes) { - Y_VERIFY(attributes.BriefState, + Y_ABORT_UNLESS(attributes.BriefState, "get_operation for operation %s has not returned \"state\" field", GetGuidAsString(*Id_).Data()); result = *attributes.BriefState; @@ -2450,7 +2450,7 @@ TMaybe<TYtError> TOperation::TOperationImpl::GetError() ValidateOperationStarted(); TMaybe<TYtError> result; UpdateAttributesAndCall(false, [&] (const TOperationAttributes& attributes) { - Y_VERIFY(attributes.Result); + Y_ABORT_UNLESS(attributes.Result); result = attributes.Result->Error; }); return result; @@ -2516,9 +2516,9 @@ void TOperation::TOperationImpl::AnalyzeUnrecognizedSpec(TNode unrecognizedSpec) } }; - Y_VERIFY(unrecognizedSpec.IsMap()); + Y_ABORT_UNLESS(unrecognizedSpec.IsMap()); for (const auto& knownFieldPath : knownUnrecognizedSpecFieldPaths) { - Y_VERIFY(!knownFieldPath.empty()); + Y_ABORT_UNLESS(!knownFieldPath.empty()); removeByPath(unrecognizedSpec, knownFieldPath.cbegin(), knownFieldPath.cend(), removeByPath); } @@ -2534,13 +2534,13 @@ void TOperation::TOperationImpl::AnalyzeUnrecognizedSpec(TNode unrecognizedSpec) void TOperation::TOperationImpl::OnStarted(const TOperationId& operationId) { auto guard = Guard(Lock_); - Y_VERIFY(!Id_, + Y_ABORT_UNLESS(!Id_, "OnStarted() called with operationId = %s for operation with id %s", GetGuidAsString(operationId).Data(), GetGuidAsString(*Id_).Data()); Id_ = operationId; - Y_VERIFY(!StartedPromise_.HasValue() && !StartedPromise_.HasException()); + Y_ABORT_UNLESS(!StartedPromise_.HasValue() && !StartedPromise_.HasException()); StartedPromise_.SetValue(); } @@ -2657,12 +2657,12 @@ void TOperation::TOperationImpl::SyncFinishOperationImpl(const TOperationAttribu { { auto guard = Guard(Lock_); - Y_VERIFY(Id_); + Y_ABORT_UNLESS(Id_); } - Y_VERIFY(attributes.BriefState, + Y_ABORT_UNLESS(attributes.BriefState, "get_operation for operation %s has not returned \"state\" field", GetGuidAsString(*Id_).Data()); - Y_VERIFY(*attributes.BriefState != EOperationBriefState::InProgress); + Y_ABORT_UNLESS(*attributes.BriefState != EOperationBriefState::InProgress); { try { @@ -2681,7 +2681,7 @@ void TOperation::TOperationImpl::SyncFinishOperationImpl(const TOperationAttribu if (*attributes.BriefState == EOperationBriefState::Completed) { CompletePromise_->SetValue(); } else if (*attributes.BriefState == EOperationBriefState::Aborted || *attributes.BriefState == EOperationBriefState::Failed) { - Y_VERIFY(attributes.Result && attributes.Result->Error); + Y_ABORT_UNLESS(attributes.Result && attributes.Result->Error); const auto& error = *attributes.Result->Error; YT_LOG_ERROR("Operation %v is `%v' with error: %v", *Id_, diff --git a/yt/cpp/mapreduce/client/operation_preparer.cpp b/yt/cpp/mapreduce/client/operation_preparer.cpp index e84dc1091f..81321d9726 100644 --- a/yt/cpp/mapreduce/client/operation_preparer.cpp +++ b/yt/cpp/mapreduce/client/operation_preparer.cpp @@ -125,7 +125,7 @@ public: private: void UpdateOperationStatus(TStringBuf err) { - Y_VERIFY(Operation_); + Y_ABORT_UNLESS(Operation_); Operation_->OnStatusUpdated( ::TStringBuilder() << "Retriable error during operation start: " << err); } @@ -683,7 +683,7 @@ TMaybe<TString> TJobPreparer::TryUploadWithDeduplication(const IItemToUpload& it TString TJobPreparer::UploadToCacheUsingApi(const IItemToUpload& itemToUpload) const { auto md5Signature = itemToUpload.CalculateMD5(); - Y_VERIFY(md5Signature.size() == 32); + Y_ABORT_UNLESS(md5Signature.size() == 32); if (auto cachedItemPath = GetItemFromCypressCache(md5Signature, itemToUpload.GetDescription())) { return *cachedItemPath; diff --git a/yt/cpp/mapreduce/client/prepare_operation.cpp b/yt/cpp/mapreduce/client/prepare_operation.cpp index 7f772dc99a..cd775f5357 100644 --- a/yt/cpp/mapreduce/client/prepare_operation.cpp +++ b/yt/cpp/mapreduce/client/prepare_operation.cpp @@ -76,7 +76,7 @@ const TVector<TTableSchema>& TOperationPreparationContext::GetInputSchemas() con schemaFutures.emplace_back(); continue; } - Y_VERIFY(Inputs_[tableIndex]); + Y_ABORT_UNLESS(Inputs_[tableIndex]); schemaFutures.push_back(batch.Get(TransactionId_, Inputs_[tableIndex]->Path_ + "/@schema", TGetOptions{})); } @@ -98,7 +98,7 @@ const TTableSchema& TOperationPreparationContext::GetInputSchema(int index) cons { auto& schema = InputSchemas_[index]; if (!InputSchemasLoaded_[index]) { - Y_VERIFY(Inputs_[index]); + Y_ABORT_UNLESS(Inputs_[index]); auto schemaNode = NRawClient::Get( RetryPolicy_->CreatePolicyForGenericRequest(), Context_, @@ -111,7 +111,7 @@ const TTableSchema& TOperationPreparationContext::GetInputSchema(int index) cons TMaybe<TYPath> TOperationPreparationContext::GetInputPath(int index) const { - Y_VERIFY(index < static_cast<int>(Inputs_.size())); + Y_ABORT_UNLESS(index < static_cast<int>(Inputs_.size())); if (Inputs_[index]) { return Inputs_[index]->Path_; } @@ -120,7 +120,7 @@ TMaybe<TYPath> TOperationPreparationContext::GetInputPath(int index) const TMaybe<TYPath> TOperationPreparationContext::GetOutputPath(int index) const { - Y_VERIFY(index < static_cast<int>(Outputs_.size())); + Y_ABORT_UNLESS(index < static_cast<int>(Outputs_.size())); if (Outputs_[index]) { return Outputs_[index]->Path_; } @@ -137,7 +137,7 @@ TSpeculativeOperationPreparationContext::TSpeculativeOperationPreparationContext , Inputs_(std::move(inputs)) , Outputs_(std::move(outputs)) { - Y_VERIFY(Inputs_.size() == previousResult.size()); + Y_ABORT_UNLESS(Inputs_.size() == previousResult.size()); } int TSpeculativeOperationPreparationContext::GetInputCount() const @@ -157,13 +157,13 @@ const TVector<TTableSchema>& TSpeculativeOperationPreparationContext::GetInputSc const TTableSchema& TSpeculativeOperationPreparationContext::GetInputSchema(int index) const { - Y_VERIFY(index < static_cast<int>(InputSchemas_.size())); + Y_ABORT_UNLESS(index < static_cast<int>(InputSchemas_.size())); return InputSchemas_[index]; } TMaybe<TYPath> TSpeculativeOperationPreparationContext::GetInputPath(int index) const { - Y_VERIFY(index < static_cast<int>(Inputs_.size())); + Y_ABORT_UNLESS(index < static_cast<int>(Inputs_.size())); if (Inputs_[index].RichYPath) { return Inputs_[index].RichYPath->Path_; } @@ -172,7 +172,7 @@ TMaybe<TYPath> TSpeculativeOperationPreparationContext::GetInputPath(int index) TMaybe<TYPath> TSpeculativeOperationPreparationContext::GetOutputPath(int index) const { - Y_VERIFY(index < static_cast<int>(Outputs_.size())); + Y_ABORT_UNLESS(index < static_cast<int>(Outputs_.size())); if (Outputs_[index].RichYPath) { return Outputs_[index].RichYPath->Path_; } diff --git a/yt/cpp/mapreduce/client/structured_table_formats.cpp b/yt/cpp/mapreduce/client/structured_table_formats.cpp index b6e82c6c15..60e3d61c99 100644 --- a/yt/cpp/mapreduce/client/structured_table_formats.cpp +++ b/yt/cpp/mapreduce/client/structured_table_formats.cpp @@ -208,7 +208,7 @@ TStructuredJobTableList CanonizeStructuredTableList(const TClientContext& contex toCanonize.emplace_back(table.RichYPath); } const auto canonized = NRawClient::CanonizeYPaths(/* retryPolicy */ nullptr, context, toCanonize); - Y_VERIFY(canonized.size() == tableList.size()); + Y_ABORT_UNLESS(canonized.size() == tableList.size()); TStructuredJobTableList result; result.reserve(tableList.size()); @@ -223,7 +223,7 @@ TVector<TRichYPath> GetPathList( const TMaybe<TVector<TTableSchema>>& jobSchemaInferenceResult, bool inferSchemaFromDescriptions) { - Y_VERIFY(!jobSchemaInferenceResult || tableList.size() == jobSchemaInferenceResult->size()); + Y_ABORT_UNLESS(!jobSchemaInferenceResult || tableList.size() == jobSchemaInferenceResult->size()); auto maybeInferSchema = [&] (const TStructuredJobTable& table, ui32 tableIndex) -> TMaybe<TTableSchema> { if (jobSchemaInferenceResult && !jobSchemaInferenceResult->at(tableIndex).Empty()) { @@ -239,7 +239,7 @@ TVector<TRichYPath> GetPathList( result.reserve(tableList.size()); for (size_t tableIndex = 0; tableIndex != tableList.size(); ++tableIndex) { const auto& table = tableList[tableIndex]; - Y_VERIFY(table.RichYPath, "Cannot get path for intermediate table"); + Y_ABORT_UNLESS(table.RichYPath, "Cannot get path for intermediate table"); auto richYPath = *table.RichYPath; if (!richYPath.Schema_) { if (auto schema = maybeInferSchema(table, tableIndex)) { @@ -373,7 +373,7 @@ std::pair<TFormat, TMaybe<TSmallJobFile>> TFormatBuilder::CreateYamrFormat( if (allowFormatFromTableAttribute && OperationOptions_.UseTableFormats_) { TVector<TRichYPath> tableList; for (const auto& table: structuredTableList) { - Y_VERIFY(table.RichYPath, "Cannot use format from table for intermediate table"); + Y_ABORT_UNLESS(table.RichYPath, "Cannot use format from table for intermediate table"); tableList.push_back(*table.RichYPath); } formatFromTableAttributes = GetTableFormats(ClientRetryPolicy_, Context_, TransactionId_, tableList); @@ -416,7 +416,7 @@ std::pair<TFormat, TMaybe<TSmallJobFile>> TFormatBuilder::CreateNodeFormat( if (nodeReaderFormat != ENodeReaderFormat::Yson) { TVector<TRichYPath> tableList; for (const auto& table: structuredTableList) { - Y_VERIFY(table.RichYPath, "Cannot use skiff with temporary tables"); + Y_ABORT_UNLESS(table.RichYPath, "Cannot use skiff with temporary tables"); tableList.emplace_back(*table.RichYPath); } skiffSchema = TryCreateSkiffSchema( @@ -515,7 +515,7 @@ std::pair<TFormat, TMaybe<TSmallJobFile>> TFormatBuilder::CreateProtobufFormat( if (!descriptor) { // It must be intermediate table, because there is no proper way to add such table to spec // (AddInput requires to specify proper message). - Y_VERIFY(!table.RichYPath, "Descriptors for all tables except intermediate must be known"); + Y_ABORT_UNLESS(!table.RichYPath, "Descriptors for all tables except intermediate must be known"); if (jobDescriptor) { descriptor = jobDescriptor; } else { @@ -532,7 +532,7 @@ std::pair<TFormat, TMaybe<TSmallJobFile>> TFormatBuilder::CreateProtobufFormat( } descriptorList.push_back(descriptor); } - Y_VERIFY(!descriptorList.empty(), "Messages for proto format are unknown (empty ProtoDescriptors)"); + Y_ABORT_UNLESS(!descriptorList.empty(), "Messages for proto format are unknown (empty ProtoDescriptors)"); return { TFormat::Protobuf(descriptorList, Context_.Config->ProtobufFormatWithDescriptors), TSmallJobFile{ diff --git a/yt/cpp/mapreduce/client/yt_poller.cpp b/yt/cpp/mapreduce/client/yt_poller.cpp index e0bea1690e..5750f5840c 100644 --- a/yt/cpp/mapreduce/client/yt_poller.cpp +++ b/yt/cpp/mapreduce/client/yt_poller.cpp @@ -89,7 +89,7 @@ void TYtPoller::WatchLoop() if (!Pending_.empty()) { InProgress_.splice(InProgress_.end(), Pending_); } - Y_VERIFY(!InProgress_.empty()); + Y_ABORT_UNLESS(!InProgress_.empty()); } TRawBatchRequest rawBatchRequest(Context_.Config); diff --git a/yt/cpp/mapreduce/http/helpers.cpp b/yt/cpp/mapreduce/http/helpers.cpp index 233a565f20..8a5fe16138 100644 --- a/yt/cpp/mapreduce/http/helpers.cpp +++ b/yt/cpp/mapreduce/http/helpers.cpp @@ -53,7 +53,7 @@ static TString GetParametersDebugString(const THttpHeader& header) TString TruncateForLogs(const TString& text, size_t maxSize) { - Y_VERIFY(maxSize > 10); + Y_ABORT_UNLESS(maxSize > 10); if (text.empty()) { static TString empty = "empty"; return empty; diff --git a/yt/cpp/mapreduce/http/http.cpp b/yt/cpp/mapreduce/http/http.cpp index d44b2638a0..c5c358c46c 100644 --- a/yt/cpp/mapreduce/http/http.cpp +++ b/yt/cpp/mapreduce/http/http.cpp @@ -101,9 +101,9 @@ private: // if error has happend. This function tries to read error response // in such cases. void HandleWriteException() { - Y_VERIFY(WriteError_ == nullptr); + Y_ABORT_UNLESS(WriteError_ == nullptr); WriteError_ = std::current_exception(); - Y_VERIFY(WriteError_ != nullptr); + Y_ABORT_UNLESS(WriteError_ != nullptr); try { HttpRequest_->GetResponseStream(); } catch (const TErrorResponse &) { @@ -774,7 +774,7 @@ size_t THttpResponse::DoRead(void* buf, size_t len) if (read == 0 && len != 0) { // THttpInput MUST return defined (but may be empty) // trailers when it is exhausted. - Y_VERIFY(HttpInput_.Trailers().Defined(), + Y_ABORT_UNLESS(HttpInput_.Trailers().Defined(), "trailers MUST be defined for exhausted stream"); CheckTrailers(HttpInput_.Trailers().GetRef()); IsExhausted_ = true; @@ -793,7 +793,7 @@ size_t THttpResponse::DoSkip(size_t len) if (skipped == 0 && len != 0) { // THttpInput MUST return defined (but may be empty) // trailers when it is exhausted. - Y_VERIFY(HttpInput_.Trailers().Defined(), + Y_ABORT_UNLESS(HttpInput_.Trailers().Defined(), "trailers MUST be defined for exhausted stream"); CheckTrailers(HttpInput_.Trailers().GetRef()); IsExhausted_ = true; @@ -964,7 +964,7 @@ THttpResponse* THttpRequest::GetResponseStream() if (!Input) { SocketInput.Reset(new TSocketInput(*Connection->Socket.Get())); if (TConfig::Get()->UseAbortableResponse) { - Y_VERIFY(!Url_.empty()); + Y_ABORT_UNLESS(!Url_.empty()); Input.Reset(new TAbortableHttpResponse(SocketInput.Get(), RequestId, HostName, Url_)); } else { Input.Reset(new THttpResponse(SocketInput.Get(), RequestId, HostName)); diff --git a/yt/cpp/mapreduce/http/http_client.cpp b/yt/cpp/mapreduce/http/http_client.cpp index a2af1182dc..6dc24c6ef2 100644 --- a/yt/cpp/mapreduce/http/http_client.cpp +++ b/yt/cpp/mapreduce/http/http_client.cpp @@ -226,7 +226,7 @@ public: CheckErrorResponse(Context_.HostName, Context_.RequestId, Response_); if (TConfig::Get()->UseAbortableResponse) { - Y_VERIFY(!Context_.Url.empty()); + Y_ABORT_UNLESS(!Context_.Url.empty()); Stream_ = std::make_unique<TAbortableCoreHttpResponse>(std::move(stream), Context_.Url); } else { Stream_ = std::move(stream); @@ -423,9 +423,9 @@ private: // if error has happend. This function tries to read error response // in such cases. void HandleWriteException() { - Y_VERIFY(WriteError_ == nullptr); + Y_ABORT_UNLESS(WriteError_ == nullptr); WriteError_ = std::current_exception(); - Y_VERIFY(WriteError_ != nullptr); + Y_ABORT_UNLESS(WriteError_ != nullptr); try { HttpRequest_->FinishWithError()->GetResponseStream(); } catch (const TErrorResponse &) { diff --git a/yt/cpp/mapreduce/interface/common.cpp b/yt/cpp/mapreduce/interface/common.cpp index 31c5990e6b..28f98713f6 100644 --- a/yt/cpp/mapreduce/interface/common.cpp +++ b/yt/cpp/mapreduce/interface/common.cpp @@ -325,14 +325,14 @@ TColumnSchema TColumnSchema::Type(EValueType type) && TColumnSchema& TColumnSchema::Type(const NTi::TTypePtr& type) & { - Y_VERIFY(type.Get(), "Cannot create column schema with nullptr type"); + Y_ABORT_UNLESS(type.Get(), "Cannot create column schema with nullptr type"); TypeV3_ = type; return *this; } TColumnSchema TColumnSchema::Type(const NTi::TTypePtr& type) && { - Y_VERIFY(type.Get(), "Cannot create column schema with nullptr type"); + Y_ABORT_UNLESS(type.Get(), "Cannot create column schema with nullptr type"); TypeV3_ = type; return *this; } @@ -526,7 +526,7 @@ TTableSchema CreateTableSchema( TTableSchema CreateTableSchema(NTi::TTypePtr type) { - Y_VERIFY(type); + Y_ABORT_UNLESS(type); TTableSchema schema; Deserialize(schema, NodeFromYsonString(NTi::NIo::AsYtSchema(type.Get()))); return schema; diff --git a/yt/cpp/mapreduce/interface/format.cpp b/yt/cpp/mapreduce/interface/format.cpp index a663e7dfa8..aec9570bc2 100644 --- a/yt/cpp/mapreduce/interface/format.cpp +++ b/yt/cpp/mapreduce/interface/format.cpp @@ -92,7 +92,7 @@ bool TFormat::IsYamredDsv() const static TString FormatName(const TFormat& format) { if (!format.Config.IsString()) { - Y_VERIFY(format.Config.IsUndefined()); + Y_ABORT_UNLESS(format.Config.IsUndefined()); return "<undefined>"; } return format.Config.AsString(); diff --git a/yt/cpp/mapreduce/interface/io-inl.h b/yt/cpp/mapreduce/interface/io-inl.h index 542749c679..fee7ba20ff 100644 --- a/yt/cpp/mapreduce/interface/io-inl.h +++ b/yt/cpp/mapreduce/interface/io-inl.h @@ -242,7 +242,7 @@ protected: template <typename U, typename TMover, typename TCacheMover> void DoMoveRowCached(U* result, TMover mover, TCacheMover cacheMover) { - Y_VERIFY(result); + Y_ABORT_UNLESS(result); switch (RowState_) { case ERowState::None: mover(result); @@ -355,7 +355,7 @@ public: }, /* cacheGetter */ [&] { auto result = dynamic_cast<const U*>(CachedRow_.Get()); - Y_VERIFY(result); + Y_ABORT_UNLESS(result); return result; }); } @@ -372,7 +372,7 @@ public: }, /* cacheMover */ [&] (U* result) { auto cast = dynamic_cast<U*>(CachedRow_.Get()); - Y_VERIFY(cast); + Y_ABORT_UNLESS(cast); result->Swap(cast); }); } @@ -430,7 +430,7 @@ public: Reader_->ReadRow(result); }, /* cacheMover */ [&] (U* result) { - Y_VERIFY((NDetail::TIndexInTuple<U, decltype(CachedRows_)>::Value) == CachedIndex_); + Y_ABORT_UNLESS((NDetail::TIndexInTuple<U, decltype(CachedRows_)>::Value) == CachedIndex_); *result = std::move(std::get<U>(CachedRows_)); }); } @@ -531,7 +531,7 @@ public: *result = std::move(std::get<U>(CachedRows_)); }, /* cacheMover */ [&] (U* result) { - Y_VERIFY((NDetail::TIndexInTuple<U, decltype(CachedRows_)>::Value) == CachedIndex_); + Y_ABORT_UNLESS((NDetail::TIndexInTuple<U, decltype(CachedRows_)>::Value) == CachedIndex_); *result = std::move(std::get<U>(CachedRows_)); }); } diff --git a/yt/cpp/mapreduce/interface/job_statistics.cpp b/yt/cpp/mapreduce/interface/job_statistics.cpp index bd9791672d..4ff8dde3cc 100644 --- a/yt/cpp/mapreduce/interface/job_statistics.cpp +++ b/yt/cpp/mapreduce/interface/job_statistics.cpp @@ -117,7 +117,7 @@ public: static void ParseNode(const TNode& node, const TString& curPath, TName2State2TaskName2Data* output) { - Y_VERIFY(node.IsMap()); + Y_ABORT_UNLESS(node.IsMap()); for (const auto& [key, value] : node.AsMap()) { if (key == "$"sv) { diff --git a/yt/cpp/mapreduce/interface/logging/yt_log.cpp b/yt/cpp/mapreduce/interface/logging/yt_log.cpp index 9fa7b91580..8948021407 100644 --- a/yt/cpp/mapreduce/interface/logging/yt_log.cpp +++ b/yt/cpp/mapreduce/interface/logging/yt_log.cpp @@ -53,7 +53,7 @@ public: const TLoggingCategory* GetCategory(TStringBuf categoryName) override { - Y_VERIFY(categoryName == CategoryName); + Y_ABORT_UNLESS(categoryName == CategoryName); return &Category_; } diff --git a/yt/cpp/mapreduce/interface/operation-inl.h b/yt/cpp/mapreduce/interface/operation-inl.h index 8d53cd446f..c1323f820f 100644 --- a/yt/cpp/mapreduce/interface/operation-inl.h +++ b/yt/cpp/mapreduce/interface/operation-inl.h @@ -573,10 +573,10 @@ int RunVanillaJob(size_t outputTableCount, IInputStream& jobStateStream) job.Load(jobStateStream); if constexpr (std::is_base_of<IVanillaJob<>, TVanillaJob>::value) { - Y_VERIFY(outputTableCount == 0, "Void vanilla job expects zero 'outputTableCount'"); + Y_ABORT_UNLESS(outputTableCount == 0, "Void vanilla job expects zero 'outputTableCount'"); job.Do(); } else { - Y_VERIFY(outputTableCount, "Vanilla job with table writer expects nonzero 'outputTableCount'"); + Y_ABORT_UNLESS(outputTableCount, "Vanilla job with table writer expects nonzero 'outputTableCount'"); using TOutputRow = typename TVanillaJob::TWriter::TRowType; THolder<IProxyOutput> rawJobWriter; diff --git a/yt/cpp/mapreduce/interface/operation.cpp b/yt/cpp/mapreduce/interface/operation.cpp index 706fc4caa4..03592b13fe 100644 --- a/yt/cpp/mapreduce/interface/operation.cpp +++ b/yt/cpp/mapreduce/interface/operation.cpp @@ -316,7 +316,7 @@ TVector<TTableSchema> TJobOperationPreparer::GetOutputSchemas() TVector<TTableSchema> result; result.reserve(OutputSchemas_.size()); for (auto& schema : OutputSchemas_) { - Y_VERIFY(schema.Defined()); + Y_ABORT_UNLESS(schema.Defined()); result.push_back(std::move(*schema)); schema.Clear(); } @@ -455,7 +455,7 @@ IOperationPtr IOperationClient::Map( ::TIntrusivePtr<IMapperBase> mapper, const TOperationOptions& options) { - Y_VERIFY(mapper.Get()); + Y_ABORT_UNLESS(mapper.Get()); return DoMap( spec, @@ -490,7 +490,7 @@ IOperationPtr IOperationClient::Reduce( ::TIntrusivePtr<IReducerBase> reducer, const TOperationOptions& options) { - Y_VERIFY(reducer.Get()); + Y_ABORT_UNLESS(reducer.Get()); return DoReduce( spec, @@ -529,7 +529,7 @@ IOperationPtr IOperationClient::JoinReduce( ::TIntrusivePtr<IReducerBase> reducer, const TOperationOptions& options) { - Y_VERIFY(reducer.Get()); + Y_ABORT_UNLESS(reducer.Get()); return DoJoinReduce( spec, @@ -543,7 +543,7 @@ IOperationPtr IOperationClient::MapReduce( ::TIntrusivePtr<IReducerBase> reducer, const TOperationOptions& options) { - Y_VERIFY(reducer.Get()); + Y_ABORT_UNLESS(reducer.Get()); return DoMapReduce( spec, @@ -560,7 +560,7 @@ IOperationPtr IOperationClient::MapReduce( ::TIntrusivePtr<IReducerBase> reducer, const TOperationOptions& options) { - Y_VERIFY(reducer.Get()); + Y_ABORT_UNLESS(reducer.Get()); return DoMapReduce( spec, diff --git a/yt/cpp/mapreduce/interface/operation.h b/yt/cpp/mapreduce/interface/operation.h index e7f1efc25b..6841bf9ee7 100644 --- a/yt/cpp/mapreduce/interface/operation.h +++ b/yt/cpp/mapreduce/interface/operation.h @@ -1943,7 +1943,7 @@ public: /// @brief Get number of output tables. i64 GetOutputTableCount() const { - Y_VERIFY(NDetail::OutputTableCount > 0); + Y_ABORT_UNLESS(NDetail::OutputTableCount > 0); return NDetail::OutputTableCount; } diff --git a/yt/cpp/mapreduce/interface/protobuf_format.cpp b/yt/cpp/mapreduce/interface/protobuf_format.cpp index 3d57ed2797..0f6895966e 100644 --- a/yt/cpp/mapreduce/interface/protobuf_format.cpp +++ b/yt/cpp/mapreduce/interface/protobuf_format.cpp @@ -478,7 +478,7 @@ public: [[nodiscard]] TGuard Enter(const Descriptor* descriptor) { if (ActiveVertices_.contains(descriptor)) { - Y_VERIFY(!Stack_.empty()); + Y_ABORT_UNLESS(!Stack_.empty()); ythrow TApiUsageError() << "Cyclic reference found for protobuf messages. " << "Consider removing " << EWrapperFieldFlag::SERIALIZATION_YT << " flag " << "somewhere on the cycle containing " << @@ -627,7 +627,7 @@ TNode MakeMapFieldsConfig( const TProtobufFieldOptions& fieldOptions, TCycleChecker& cycleChecker) { - Y_VERIFY(fieldDescriptor->is_map()); + Y_ABORT_UNLESS(fieldDescriptor->is_map()); auto message = fieldDescriptor->message_type(); switch (fieldOptions.MapMode) { case EProtobufMapMode::ListOfStructsLegacy: @@ -1306,7 +1306,7 @@ NTi::TTypePtr TTableSchemaInferrer::GetMessageType( const FieldDescriptor& fieldDescriptor, TProtobufFieldOptions defaultFieldOptions) { - Y_VERIFY(fieldDescriptor.message_type()); + Y_ABORT_UNLESS(fieldDescriptor.message_type()); const auto& messageDescriptor = *fieldDescriptor.message_type(); auto members = GetMessageMembers( fieldDescriptor.full_name(), @@ -1320,7 +1320,7 @@ NTi::TTypePtr TTableSchemaInferrer::GetMapType( const FieldDescriptor& fieldDescriptor, const TProtobufFieldOptions& fieldOptions) { - Y_VERIFY(fieldDescriptor.is_map()); + Y_ABORT_UNLESS(fieldDescriptor.is_map()); switch (fieldOptions.MapMode) { case EProtobufMapMode::ListOfStructsLegacy: case EProtobufMapMode::ListOfStructs: { @@ -1340,16 +1340,16 @@ NTi::TTypePtr TTableSchemaInferrer::GetMapType( case EProtobufMapMode::Dict: case EProtobufMapMode::OptionalDict: { auto message = fieldDescriptor.message_type(); - Y_VERIFY(message->field_count() == 2); + Y_ABORT_UNLESS(message->field_count() == 2); auto keyVariant = GetScalarFieldType(*message->field(0), TProtobufFieldOptions{}); - Y_VERIFY(std::holds_alternative<EValueType>(keyVariant)); + Y_ABORT_UNLESS(std::holds_alternative<EValueType>(keyVariant)); auto key = std::get<EValueType>(keyVariant); TProtobufFieldOptions embeddedOptions; embeddedOptions.SerializationMode = EProtobufSerializationMode::Yt; auto valueVariant = GetFieldType(*message->field(1), embeddedOptions); - Y_VERIFY(std::holds_alternative<NTi::TTypePtr>(valueVariant)); + Y_ABORT_UNLESS(std::holds_alternative<NTi::TTypePtr>(valueVariant)); auto value = std::get<NTi::TTypePtr>(valueVariant); - Y_VERIFY(value->IsOptional()); + Y_ABORT_UNLESS(value->IsOptional()); value = value->AsOptional()->GetItemType(); auto dict = NTi::Dict(ToTypeV3(key, true), value); if (fieldOptions.MapMode == EProtobufMapMode::OptionalDict) { diff --git a/yt/cpp/mapreduce/interface/serialize.cpp b/yt/cpp/mapreduce/interface/serialize.cpp index ae05d9f50d..8557985069 100644 --- a/yt/cpp/mapreduce/interface/serialize.cpp +++ b/yt/cpp/mapreduce/interface/serialize.cpp @@ -196,7 +196,7 @@ void Serialize(const TColumnSchema& columnSchema, NYson::IYsonConsumer* consumer if (typeV3.IsString()) { result = typeV3.AsString(); } else if (typeV3.IsMap() && typeV3.Size() == 1) { - Y_VERIFY(typeV3["type_name"].IsString(), "invalid type is passed"); + Y_ABORT_UNLESS(typeV3["type_name"].IsString(), "invalid type is passed"); result = typeV3["type_name"].AsString(); } if (result) { diff --git a/yt/cpp/mapreduce/io/proto_table_writer.cpp b/yt/cpp/mapreduce/io/proto_table_writer.cpp index 160ea78f50..955bba26e1 100644 --- a/yt/cpp/mapreduce/io/proto_table_writer.cpp +++ b/yt/cpp/mapreduce/io/proto_table_writer.cpp @@ -167,7 +167,7 @@ void TLenvalProtoTableWriter::AddRow(const Message& row, size_t tableIndex) { ValidateProtoDescriptor(row, tableIndex, Descriptors_, false); - Y_VERIFY(row.GetReflection()->GetUnknownFields(row).empty(), + Y_ABORT_UNLESS(row.GetReflection()->GetUnknownFields(row).empty(), "Message has unknown fields. This probably means bug in client code.\n" "Message: %s", row.DebugString().data()); diff --git a/yt/cpp/mapreduce/raw_client/raw_batch_request.cpp b/yt/cpp/mapreduce/raw_client/raw_batch_request.cpp index 8ede410c38..1568c3d85e 100644 --- a/yt/cpp/mapreduce/raw_client/raw_batch_request.cpp +++ b/yt/cpp/mapreduce/raw_client/raw_batch_request.cpp @@ -592,8 +592,8 @@ TFuture<TMultiTablePartitions> TRawBatchRequest::GetTablePartitions( void TRawBatchRequest::FillParameterList(size_t maxSize, TNode* result, TInstant* nextTry) const { - Y_VERIFY(result); - Y_VERIFY(nextTry); + Y_ABORT_UNLESS(result); + Y_ABORT_UNLESS(nextTry); *nextTry = TInstant(); maxSize = Min(maxSize, BatchItemList_.size()); @@ -626,7 +626,7 @@ void TRawBatchRequest::ParseResponse( TRawBatchRequest* retryBatch, TInstant now) { - Y_VERIFY(retryBatch); + Y_ABORT_UNLESS(retryBatch); EnsureType(node, TNode::List); auto& responseList = node.AsList(); diff --git a/yt/yt/core/ytree/ypath_resolver.cpp b/yt/yt/core/ytree/ypath_resolver.cpp index 1b24afefb8..3f293e102b 100644 --- a/yt/yt/core/ytree/ypath_resolver.cpp +++ b/yt/yt/core/ytree/ypath_resolver.cpp @@ -157,7 +157,7 @@ std::optional<TResult> TryParseImpl(TStringBuf yson, const TYPath& path, bool is if (expected != EExpectedItem::BeginAttribute) { return std::nullopt; } - Y_VERIFY(literal.has_value()); + Y_ABORT_UNLESS(literal.has_value()); if (!ParseMapOrAttributesUntilKey(&cursor, *literal)) { return std::nullopt; } @@ -167,7 +167,7 @@ std::optional<TResult> TryParseImpl(TStringBuf yson, const TYPath& path, bool is if (expected != EExpectedItem::BeginMapOrList) { return std::nullopt; } - Y_VERIFY(literal.has_value()); + Y_ABORT_UNLESS(literal.has_value()); if (!ParseMapOrAttributesUntilKey(&cursor, *literal)) { return std::nullopt; } @@ -177,7 +177,7 @@ std::optional<TResult> TryParseImpl(TStringBuf yson, const TYPath& path, bool is if (expected != EExpectedItem::BeginMapOrList) { return std::nullopt; } - Y_VERIFY(literal.has_value()); + Y_ABORT_UNLESS(literal.has_value()); int index; if (!TryFromString(*literal, index)) { return std::nullopt; diff --git a/yt/yt/library/formats/protobuf.cpp b/yt/yt/library/formats/protobuf.cpp index e4c29652fa..99d4e041ff 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_VERIFY(!Stack_.empty()); + Y_ABORT_UNLESS(!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_VERIFY(fieldDescriptor->is_map()); + Y_ABORT_UNLESS(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 925dabd9ff..ba7ddaa076 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_VERIFY(maybeEmbeddedChildIndex); + Y_ABORT_UNLESS(maybeEmbeddedChildIndex); embeddedChildIndex = *maybeEmbeddedChildIndex; } diff --git a/yt/yt/library/formats/protobuf_writer.cpp b/yt/yt/library/formats/protobuf_writer.cpp index f4321cd68a..0a32808277 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_VERIFY(embeddings[parentEmbeddingIndex].ParentEmbeddingIndex == TProtobufWriterEmbeddingDescription::InvalidIndex); + Y_ABORT_UNLESS(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 4d84770ccc..0196f7890d 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_VERIFY(!schemas.empty()); + Y_ABORT_UNLESS(!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 1b428261c2..0190b7f8e5 100644 --- a/yt/yt/library/numeric/binary_search-inl.h +++ b/yt/yt/library/numeric/binary_search-inl.h @@ -59,9 +59,9 @@ constexpr TInt IntegerLowerBound(TInt lo, TInt hi, TPredicate&& predicate) using TUInt = std::make_unsigned_t<TInt>; - Y_VERIFY(lo <= hi); + Y_ABORT_UNLESS(lo <= hi); - Y_VERIFY(predicate(hi)); + Y_ABORT_UNLESS(predicate(hi)); if (predicate(lo)) { return lo; } @@ -88,9 +88,9 @@ constexpr TInt IntegerInverseLowerBound(TInt lo, TInt hi, TPredicate&& predicate using TUInt = std::make_unsigned_t<TInt>; - Y_VERIFY(lo <= hi); + Y_ABORT_UNLESS(lo <= hi); - Y_VERIFY(predicate(lo)); + Y_ABORT_UNLESS(predicate(lo)); if (predicate(hi)) { return hi; } @@ -113,13 +113,13 @@ constexpr TInt IntegerInverseLowerBound(TInt lo, TInt hi, TPredicate&& predicate template <class TPredicate> double FloatingPointLowerBound(double lo, double hi, TPredicate&& predicate) { - Y_VERIFY(!std::isnan(lo)); - Y_VERIFY(!std::isnan(hi)); - Y_VERIFY(lo <= hi); + Y_ABORT_UNLESS(!std::isnan(lo)); + Y_ABORT_UNLESS(!std::isnan(hi)); + Y_ABORT_UNLESS(lo <= hi); // NB(antonkikh): Note that this handles the case when |hi == -0.0| and |lo == 0.0|. if (lo == hi) { - Y_VERIFY(predicate(hi)); + Y_ABORT_UNLESS(predicate(hi)); return hi; } @@ -133,13 +133,13 @@ double FloatingPointLowerBound(double lo, double hi, TPredicate&& predicate) template <class TPredicate> double FloatingPointInverseLowerBound(double lo, double hi, TPredicate&& predicate) { - Y_VERIFY(!std::isnan(lo)); - Y_VERIFY(!std::isnan(hi)); - Y_VERIFY(lo <= hi); + Y_ABORT_UNLESS(!std::isnan(lo)); + Y_ABORT_UNLESS(!std::isnan(hi)); + Y_ABORT_UNLESS(lo <= hi); // NB(antonkikh): Note that this handles the case when |hi == -0.0| and |lo == 0.0|. if (lo == hi) { - Y_VERIFY(predicate(lo)); + Y_ABORT_UNLESS(predicate(lo)); return lo; } diff --git a/yt/yt/library/numeric/double_array.h b/yt/yt/library/numeric/double_array.h index 58555d93dd..c3a5ec19d9 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_VERIFY(vec1[3] == 4); -// Y_VERIFY(TDoubleArray<4>::All(vec1, [] (double x) { return x > 0; })); -// Y_VERIFY(MinComponent(vec1) == 1); +// Y_ABORT_UNLESS(vec1[3] == 4); +// Y_ABORT_UNLESS(TDoubleArray<4>::All(vec1, [] (double x) { return x > 0; })); +// Y_ABORT_UNLESS(MinComponent(vec1) == 1); // // TDoubleArray<4> vec2 = {4, 3, 2, 1}; -// Y_VERIFY(vec1 + vec2 == TDoubleArray<4>::FromDouble(5)); +// Y_ABORT_UNLESS(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_VERIFY(TDoubleArray<4>::All(vec1, vec1Square, [] (double x, double y) { return y == x * x; })); +// Y_ABORT_UNLESS(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 1a1caac023..c5bf1d587b 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_VERIFY(LeftBound_ <= RightBound_); + Y_ABORT_UNLESS(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_VERIFY(IsDefinedAt(x)); + Y_ABORT_UNLESS(IsDefinedAt(x)); return LeftRightLimitAt(x).first; } template <class TValue> TValue TPiecewiseSegment<TValue>::RightLimitAt(double x) const { - Y_VERIFY(IsDefinedAt(x)); + Y_ABORT_UNLESS(IsDefinedAt(x)); return LeftRightLimitAt(x).second; } template <class TValue> std::pair<TValue, TValue> TPiecewiseSegment<TValue>::LeftRightLimitAt(double x) const { - Y_VERIFY(IsDefinedAt(x)); + Y_ABORT_UNLESS(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_VERIFY(IsDefinedAt(x)); + Y_ABORT_UNLESS(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_VERIFY(vec->back().RightBound() == segment.LeftBound()); - Y_VERIFY(vec->back().RightValue() == segment.LeftValue()); + Y_ABORT_UNLESS(vec->back().RightBound() == segment.LeftBound()); + Y_ABORT_UNLESS(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_VERIFY(mergedSegment.IsVertical()); + Y_ABORT_UNLESS(mergedSegment.IsVertical()); vec->back() = mergedSegment; return; } if (leftSegment.IsHorizontal() && rightSegment.IsHorizontal()) { - Y_VERIFY(mergedSegment.IsHorizontal()); + Y_ABORT_UNLESS(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_VERIFY(resultLeftBound <= resultRightBound); + Y_ABORT_UNLESS(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_VERIFY(leftBound < rightBound); + Y_ABORT_UNLESS(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_VERIFY(segmentLo.IsDefinedOn(leftBound, rightBound)); - Y_VERIFY(segmentHi.IsDefinedOn(leftBound, rightBound)); + Y_ABORT_UNLESS(segmentLo.IsDefinedOn(leftBound, rightBound)); + Y_ABORT_UNLESS(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_VERIFY(!funcs.empty()); + Y_ABORT_UNLESS(!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_VERIFY(RightPoint_->first == segment.LeftBound()); - Y_VERIFY(RightPoint_->second == segment.LeftValue()); + Y_ABORT_UNLESS(RightPoint_->first == segment.LeftBound()); + Y_ABORT_UNLESS(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_VERIFY(!criticalPoints.empty()); + Y_ABORT_UNLESS(!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_VERIFY(criticalPoints.front() == leftBound); - Y_VERIFY(criticalPoints.back() == rightBound); + Y_ABORT_UNLESS(criticalPoints.front() == leftBound); + Y_ABORT_UNLESS(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_VERIFY(!Segments_.empty()); + Y_ABORT_UNLESS(!Segments_.empty()); } template <class TValue> @@ -494,7 +494,7 @@ TValue TPiecewiseLinearFunction<TValue>::LeftFunctionValue() const template <class TValue> TValue TPiecewiseLinearFunction<TValue>::RightFunctionValue() const { - Y_VERIFY(!Segments_.back().IsVertical()); + Y_ABORT_UNLESS(!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_VERIFY(it != begin(Segments_)); + Y_ABORT_UNLESS(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_VERIFY(!Segments_.front().IsVertical()); + Y_ABORT_UNLESS(!Segments_.front().IsVertical()); } return *this; @@ -682,7 +682,7 @@ TPiecewiseLinearFunction<TValue>& TPiecewiseLinearFunction<TValue>::TrimRightInp Segments_.back() = TSegment({argument, value}, {argument, value}); } - Y_VERIFY(!Segments_.back().IsVertical()); + Y_ABORT_UNLESS(!Segments_.back().IsVertical()); } return *this; @@ -763,9 +763,9 @@ TPiecewiseLinearFunction<TValue> TPiecewiseLinearFunction<TValue>::Narrow( double newLeftBound, double newRightBound) const { - Y_VERIFY(IsDefinedAt(newLeftBound)); - Y_VERIFY(IsDefinedAt(newRightBound)); - Y_VERIFY(newLeftBound <= newRightBound); + Y_ABORT_UNLESS(IsDefinedAt(newLeftBound)); + Y_ABORT_UNLESS(IsDefinedAt(newRightBound)); + Y_ABORT_UNLESS(newLeftBound <= newRightBound); return *this + Constant(newLeftBound, newRightBound, TValue{}); } @@ -789,7 +789,7 @@ TPiecewiseLinearFunction<TValue> TPiecewiseLinearFunction<TValue>::Extend( double newRightBound, const TValue& newRightValue) const { - Y_VERIFY(newLeftBound <= LeftFunctionBound()); + Y_ABORT_UNLESS(newLeftBound <= LeftFunctionBound()); TBuilder builder; @@ -870,7 +870,7 @@ template <class TValue> TPiecewiseLinearFunction<TValue> TPiecewiseLinearFunction<TValue>::Sum( const std::vector<TPiecewiseLinearFunction<TValue>>& funcs) { - Y_VERIFY(!funcs.empty()); + Y_ABORT_UNLESS(!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_VERIFY(resultLeftBound <= resultRightBound); + Y_ABORT_UNLESS(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_VERIFY(IsDefinedAt(other.LeftLimitAt(other.LeftFunctionBound()))); - Y_VERIFY(IsDefinedAt(other.RightLimitAt(other.RightFunctionBound()))); + Y_ABORT_UNLESS(IsDefinedAt(other.LeftLimitAt(other.LeftFunctionBound()))); + Y_ABORT_UNLESS(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_VERIFY(result.LeftFunctionBound() == other.LeftFunctionBound()); - Y_VERIFY(result.RightFunctionBound() == other.RightFunctionBound()); + Y_ABORT_UNLESS(result.LeftFunctionBound() == other.LeftFunctionBound()); + Y_ABORT_UNLESS(result.RightFunctionBound() == other.RightFunctionBound()); return result; } |