aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-erm <robot-erm@yandex-team.com>2024-01-25 11:11:38 +0300
committerrobot-erm <robot-erm@yandex-team.com>2024-01-25 11:32:49 +0300
commitcbf9c434c0d9cb893e267be898fc85e81127cf62 (patch)
tree9d8594b3601da653b67298666625d0a6c2be78ad
parent42db3295ba5bc7fffa4b289c9010d802e2d7911c (diff)
downloadydb-cbf9c434c0d9cb893e267be898fc85e81127cf62.tar.gz
erm: Add new version for `@yatool/prebuilder`: `0.5.1` and set `0.5.1` as default
Executed command: `./erm --verbose --profile update @yatool/prebuilder`
-rw-r--r--yt/cpp/mapreduce/client/file_writer.cpp5
-rw-r--r--yt/cpp/mapreduce/client/file_writer.h1
-rw-r--r--yt/cpp/mapreduce/client/retryful_writer.cpp2
-rw-r--r--yt/cpp/mapreduce/client/retryful_writer.h2
-rw-r--r--yt/cpp/mapreduce/client/retryless_writer.cpp2
-rw-r--r--yt/cpp/mapreduce/client/retryless_writer.h4
-rw-r--r--yt/cpp/mapreduce/interface/client_method_options.h20
-rw-r--r--yt/cpp/mapreduce/interface/finish_or_die.h6
-rw-r--r--yt/cpp/mapreduce/interface/io-inl.h2
9 files changed, 36 insertions, 8 deletions
diff --git a/yt/cpp/mapreduce/client/file_writer.cpp b/yt/cpp/mapreduce/client/file_writer.cpp
index 5a9b9a1f58..d273731e1d 100644
--- a/yt/cpp/mapreduce/client/file_writer.cpp
+++ b/yt/cpp/mapreduce/client/file_writer.cpp
@@ -16,7 +16,8 @@ TFileWriter::TFileWriter(
const TClientContext& context,
const TTransactionId& transactionId,
const TFileWriterOptions& options)
- : RetryfulWriter_(
+ : AutoFinish_(options.AutoFinish_)
+ , RetryfulWriter_(
std::move(clientRetryPolicy),
std::move(transactionPinger),
context,
@@ -29,7 +30,7 @@ TFileWriter::TFileWriter(
TFileWriter::~TFileWriter()
{
- NDetail::FinishOrDie(this, "TFileWriter");
+ NDetail::FinishOrDie(this, AutoFinish_, "TFileWriter");
}
void TFileWriter::DoWrite(const void* buf, size_t len)
diff --git a/yt/cpp/mapreduce/client/file_writer.h b/yt/cpp/mapreduce/client/file_writer.h
index 259f778ea7..ae143a75be 100644
--- a/yt/cpp/mapreduce/client/file_writer.h
+++ b/yt/cpp/mapreduce/client/file_writer.h
@@ -30,6 +30,7 @@ protected:
size_t GetBufferMemoryUsage() const override;
private:
+ const bool AutoFinish_;
TRetryfulWriter RetryfulWriter_;
static const size_t BUFFER_SIZE = 64 << 20;
};
diff --git a/yt/cpp/mapreduce/client/retryful_writer.cpp b/yt/cpp/mapreduce/client/retryful_writer.cpp
index 057fb5e7f0..55165b17ff 100644
--- a/yt/cpp/mapreduce/client/retryful_writer.cpp
+++ b/yt/cpp/mapreduce/client/retryful_writer.cpp
@@ -17,7 +17,7 @@ namespace NYT {
TRetryfulWriter::~TRetryfulWriter()
{
- NDetail::FinishOrDie(this, "TRetryfulWriter");
+ NDetail::FinishOrDie(this, AutoFinish_, "TRetryfulWriter");
}
void TRetryfulWriter::CheckWriterState()
diff --git a/yt/cpp/mapreduce/client/retryful_writer.h b/yt/cpp/mapreduce/client/retryful_writer.h
index 0b345daabf..c2de332bff 100644
--- a/yt/cpp/mapreduce/client/retryful_writer.h
+++ b/yt/cpp/mapreduce/client/retryful_writer.h
@@ -39,6 +39,7 @@ public:
: ClientRetryPolicy_(std::move(clientRetryPolicy))
, TransactionPinger_(std::move(transactionPinger))
, Context_(context)
+ , AutoFinish_(options.AutoFinish_)
, Command_(command)
, Format_(format)
, BufferSize_(GetBufferSize(options.WriterOptions_))
@@ -91,6 +92,7 @@ private:
const IClientRetryPolicyPtr ClientRetryPolicy_;
const ITransactionPingerPtr TransactionPinger_;
const TClientContext Context_;
+ const bool AutoFinish_;
TString Command_;
TMaybe<TFormat> Format_;
const size_t BufferSize_;
diff --git a/yt/cpp/mapreduce/client/retryless_writer.cpp b/yt/cpp/mapreduce/client/retryless_writer.cpp
index e3cf7cba06..dcda69bce4 100644
--- a/yt/cpp/mapreduce/client/retryless_writer.cpp
+++ b/yt/cpp/mapreduce/client/retryless_writer.cpp
@@ -8,7 +8,7 @@ namespace NYT {
TRetrylessWriter::~TRetrylessWriter()
{
- NDetail::FinishOrDie(this, "TRetrylessWriter");
+ NDetail::FinishOrDie(this, AutoFinish_, "TRetrylessWriter");
}
void TRetrylessWriter::DoFinish()
diff --git a/yt/cpp/mapreduce/client/retryless_writer.h b/yt/cpp/mapreduce/client/retryless_writer.h
index 0a1b3865ee..6916cddbf6 100644
--- a/yt/cpp/mapreduce/client/retryless_writer.h
+++ b/yt/cpp/mapreduce/client/retryless_writer.h
@@ -1,7 +1,5 @@
#pragma once
-#include "transaction.h"
-
#include <yt/cpp/mapreduce/http/helpers.h>
#include <yt/cpp/mapreduce/http/http.h>
#include <yt/cpp/mapreduce/http/http_client.h>
@@ -36,6 +34,7 @@ public:
size_t bufferSize,
const TWriterOptions& options)
: BufferSize_(bufferSize)
+ , AutoFinish_(options.AutoFinish_)
{
THttpHeader header("PUT", command);
header.SetInputFormat(format);
@@ -72,6 +71,7 @@ protected:
private:
const size_t BufferSize_ = 0;
+ const bool AutoFinish_;
bool Running_ = true;
NHttpClient::IHttpRequestPtr Request_;
diff --git a/yt/cpp/mapreduce/interface/client_method_options.h b/yt/cpp/mapreduce/interface/client_method_options.h
index b5f0f1e34e..24607de424 100644
--- a/yt/cpp/mapreduce/interface/client_method_options.h
+++ b/yt/cpp/mapreduce/interface/client_method_options.h
@@ -538,6 +538,16 @@ struct TFileWriterOptions
FLUENT_FIELD_OPTION(bool, ComputeMD5);
///
+ /// @brief Wheter to call Finish automatically in writer destructor.
+ ///
+ /// If set to true (default) Finish() is called automatically in the destructor of writer.
+ /// It is convenient for simple usecases but might be error-prone if writing exception safe code
+ /// (In case of exceptions it's common to abort writer and not commit partial data).
+ ///
+ /// If set to false Finish() has to be called explicitly.
+ FLUENT_FIELD_DEFAULT(bool, AutoFinish, true);
+
+ ///
/// @brief Options to control how YT server side writes data.
///
/// @see NYT::TWriterOptions
@@ -689,6 +699,16 @@ struct TTableWriterOptions
FLUENT_FIELD_OPTION(bool, InferSchema);
///
+ /// @brief Wheter to call Finish automatically in writer destructor.
+ ///
+ /// If set to true (default) Finish() is called automatically in the destructor of writer.
+ /// It is convenient for simple usecases but might be error-prone if writing exception safe code
+ /// (In case of exceptions it's common to abort writer and not commit partial data).
+ ///
+ /// If set to false Finish() has to be called explicitly.
+ FLUENT_FIELD_DEFAULT(bool, AutoFinish, true);
+
+ ///
/// @brief Options to control how YT server side writes data.
///
/// @see NYT::TWriterOptions
diff --git a/yt/cpp/mapreduce/interface/finish_or_die.h b/yt/cpp/mapreduce/interface/finish_or_die.h
index cb8d96c454..a6e190328f 100644
--- a/yt/cpp/mapreduce/interface/finish_or_die.h
+++ b/yt/cpp/mapreduce/interface/finish_or_die.h
@@ -10,8 +10,12 @@ namespace NYT::NDetail {
////////////////////////////////////////////////////////////////////////////////
template <typename T>
-void FinishOrDie(T* pThis, const char* className) noexcept
+void FinishOrDie(T* pThis, bool autoFinish, const char* className) noexcept
{
+ if (!autoFinish) {
+ return;
+ }
+
auto fail = [&] (const char* what) {
Y_ABORT(
"\n\n"
diff --git a/yt/cpp/mapreduce/interface/io-inl.h b/yt/cpp/mapreduce/interface/io-inl.h
index fee7ba20ff..7324eaca20 100644
--- a/yt/cpp/mapreduce/interface/io-inl.h
+++ b/yt/cpp/mapreduce/interface/io-inl.h
@@ -784,7 +784,7 @@ public:
~TTableWriterBase() override
{
if (Locks_.RefCount() == 1) {
- NDetail::FinishOrDie(this, "TTableWriterBase");
+ NDetail::FinishOrDie(this, /*autoFinish*/ true, "TTableWriterBase");
}
}