diff options
author | Innokentii Mokin <innokentii@ydb.tech> | 2024-01-27 10:01:54 +0000 |
---|---|---|
committer | Innokentii Mokin <innokentii@ydb.tech> | 2024-01-27 10:01:54 +0000 |
commit | 621e3d86c4e02bf3c88bb68e5aba5856fbf0185d (patch) | |
tree | 2d517d0985015d27ce6862003509de502be44ccc /yt/cpp | |
parent | a7dad28338e49d920879eb2b3e728ee6dd166b6e (diff) | |
parent | 00b9982cd019afca788639aa8279f2dc1f342383 (diff) | |
download | ydb-621e3d86c4e02bf3c88bb68e5aba5856fbf0185d.tar.gz |
Merge branch 'mergelibs11' into main
Diffstat (limited to 'yt/cpp')
-rw-r--r-- | yt/cpp/mapreduce/client/file_writer.cpp | 5 | ||||
-rw-r--r-- | yt/cpp/mapreduce/client/file_writer.h | 1 | ||||
-rw-r--r-- | yt/cpp/mapreduce/client/retryful_writer.cpp | 2 | ||||
-rw-r--r-- | yt/cpp/mapreduce/client/retryful_writer.h | 2 | ||||
-rw-r--r-- | yt/cpp/mapreduce/client/retryless_writer.cpp | 2 | ||||
-rw-r--r-- | yt/cpp/mapreduce/client/retryless_writer.h | 4 | ||||
-rw-r--r-- | yt/cpp/mapreduce/client/ya.make | 15 | ||||
-rw-r--r-- | yt/cpp/mapreduce/interface/client_method_options.h | 20 | ||||
-rw-r--r-- | yt/cpp/mapreduce/interface/finish_or_die.h | 6 | ||||
-rw-r--r-- | yt/cpp/mapreduce/interface/io-inl.h | 2 | ||||
-rw-r--r-- | yt/cpp/mapreduce/interface/operation.h | 13 |
11 files changed, 53 insertions, 19 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/client/ya.make b/yt/cpp/mapreduce/client/ya.make index c159492808..3696a9ba8f 100644 --- a/yt/cpp/mapreduce/client/ya.make +++ b/yt/cpp/mapreduce/client/ya.make @@ -46,17 +46,10 @@ PEERDIR( yt/cpp/mapreduce/raw_client ) -IF (ARCH_X86_64 OR OS_DARWIN) - PEERDIR( - yt/yt/core - yt/yt/core/http - ) -ELSE() - # Suppress yamaker's WBadIncl error on exotic platforms - PEERDIR( - yt/yt_proto/yt/core - ) -ENDIF() +PEERDIR( + yt/yt/core + yt/yt/core/http +) IF (BUILD_TYPE == "PROFILE") PEERDIR( 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"); } } diff --git a/yt/cpp/mapreduce/interface/operation.h b/yt/cpp/mapreduce/interface/operation.h index 31252c2737..69c873090d 100644 --- a/yt/cpp/mapreduce/interface/operation.h +++ b/yt/cpp/mapreduce/interface/operation.h @@ -1990,6 +1990,19 @@ public: virtual void Load(IInputStream& stream) override { Load(&stream); } \ Y_PASS_VA_ARGS(Y_SAVELOAD_DEFINE(__VA_ARGS__)) +/// +/// @brief Same as the macro above, but also calls Base class's SaveLoad methods. +#define Y_SAVELOAD_JOB_DERIVED(Base, ...) \ + virtual void Save(IOutputStream& stream) const override { \ + Base::Save(stream); \ + Save(&stream); \ + } \ + virtual void Load(IInputStream& stream) override { \ + Base::Load(stream); \ + Load(&stream); \ + } \ + Y_PASS_VA_ARGS(Y_SAVELOAD_DEFINE(__VA_ARGS__)) + //////////////////////////////////////////////////////////////////////////////// /// |