Browse Source

Y_VERIFY->Y_ABORT_UNLESS at ^yt

https://clubs.at.yandex-team.ru/arcadia/29404
ilnurkh 1 year ago
parent
commit
6ef6895772

+ 1 - 1
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;

+ 1 - 1
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_,

+ 1 - 1
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);

+ 1 - 1
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();

+ 3 - 3
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;
     }

+ 19 - 19
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_,

+ 2 - 2
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;

+ 8 - 8
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_;
     }

+ 7 - 7
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{

+ 1 - 1
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);

Some files were not shown because too many files changed in this diff