diff options
| author | hiddenpath <[email protected]> | 2025-06-27 17:41:44 +0300 |
|---|---|---|
| committer | hiddenpath <[email protected]> | 2025-06-27 18:28:53 +0300 |
| commit | 2ba7152d23f9dcbdc99680fbd0bc87d41868b57a (patch) | |
| tree | 158be114e70df70c1dc259b286eaf9319f9d06fb /yt/cpp/mapreduce/http_client/raw_client.cpp | |
| parent | eb899d349e304f6f2d8abca99824bd084cdd1775 (diff) | |
YT-23616: Introduce WriteFile RPC implementation
commit_hash:627b3fd7979f64a7365a590bca09a1c53c23464a
Diffstat (limited to 'yt/cpp/mapreduce/http_client/raw_client.cpp')
| -rw-r--r-- | yt/cpp/mapreduce/http_client/raw_client.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/yt/cpp/mapreduce/http_client/raw_client.cpp b/yt/cpp/mapreduce/http_client/raw_client.cpp index f50b239c2aa..d2c64257222 100644 --- a/yt/cpp/mapreduce/http_client/raw_client.cpp +++ b/yt/cpp/mapreduce/http_client/raw_client.cpp @@ -767,6 +767,48 @@ std::unique_ptr<IInputStream> THttpRawClient::ReadTable( return std::make_unique<NHttpClient::THttpResponseStream>(std::move(responseInfo)); } +struct THttpRequestStream + : public IOutputStream +{ +public: + THttpRequestStream(NHttpClient::IHttpRequestPtr request) + : Request_(std::move(request)) + , Underlying_(Request_->GetStream()) + { } + +private: + void DoWrite(const void* buf, size_t len) override + { + Underlying_->Write(buf, len); + } + + void DoFinish() override + { + Underlying_->Finish(); + Request_->Finish()->GetResponse(); + } + +private: + NHttpClient::IHttpRequestPtr Request_; + IOutputStream* Underlying_; +}; + +std::unique_ptr<IOutputStream> THttpRawClient::WriteFile( + const TTransactionId& transactionId, + const TRichYPath& path, + const TFileWriterOptions& options) +{ + THttpHeader header("PUT", GetWriteFileCommand(Context_.Config->ApiVersion)); + header.AddTransactionId(transactionId); + header.SetRequestCompression(ToString(Context_.Config->ContentEncoding)); + header.MergeParameters(FormIORequestParameters(path, options)); + + TRequestConfig config; + config.IsHeavy = true; + auto request = StartRequestWithoutRetry(Context_, header, config); + return std::make_unique<THttpRequestStream>(std::move(request)); +} + std::unique_ptr<IInputStream> THttpRawClient::ReadTablePartition( const TString& cookie, const TMaybe<TFormat>& format, |
