summaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/client/structured_table_formats.cpp
diff options
context:
space:
mode:
authorhiddenpath <[email protected]>2024-12-13 15:22:36 +0300
committerhiddenpath <[email protected]>2024-12-13 17:04:18 +0300
commit09c88b035d29fac5fd49de2fbc3c71e2d2a80754 (patch)
treea84b5b2de4dcdf85c3b22b9cac7e984aebb8b68d /yt/cpp/mapreduce/client/structured_table_formats.cpp
parent615edba542d9394b0eae47ef957ec2257549cfdd (diff)
yt/cpp/mapreduce: move Get, TryGet, Exists, MultisetAttributes to THttpRawClient
commit_hash:bd2228f98fa92de408ca850f9bc1608fdf99e7f5
Diffstat (limited to 'yt/cpp/mapreduce/client/structured_table_formats.cpp')
-rw-r--r--yt/cpp/mapreduce/client/structured_table_formats.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/yt/cpp/mapreduce/client/structured_table_formats.cpp b/yt/cpp/mapreduce/client/structured_table_formats.cpp
index 6dba1e14359..a2f47af3aeb 100644
--- a/yt/cpp/mapreduce/client/structured_table_formats.cpp
+++ b/yt/cpp/mapreduce/client/structured_table_formats.cpp
@@ -5,19 +5,20 @@
#include <yt/cpp/mapreduce/common/retry_lib.h>
+#include <yt/cpp/mapreduce/http/retry_request.h>
+
+#include <yt/cpp/mapreduce/interface/common.h>
+#include <yt/cpp/mapreduce/interface/raw_client.h>
+
#include <yt/cpp/mapreduce/io/yamr_table_reader.h>
#include <yt/cpp/mapreduce/library/table_schema/protobuf.h>
-#include <yt/cpp/mapreduce/interface/common.h>
-
#include <yt/cpp/mapreduce/raw_client/raw_requests.h>
#include <library/cpp/type_info/type_info.h>
#include <library/cpp/yson/writer.h>
-#include <memory>
-
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
@@ -66,15 +67,26 @@ TMaybe<TNode> GetCommonTableFormat(
TMaybe<TNode> GetTableFormat(
const IClientRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
+ const IRawClientPtr& rawClient,
const TTransactionId& transactionId,
const TRichYPath& path)
{
auto formatPath = path.Path_ + "/@_format";
- if (!NDetail::NRawClient::Exists(retryPolicy->CreatePolicyForGenericRequest(), context, transactionId, formatPath)) {
+
+ auto exists = NDetail::RequestWithRetry<bool>(
+ retryPolicy->CreatePolicyForGenericRequest(),
+ [&rawClient, &transactionId, &formatPath] (TMutationId& mutationId) {
+ return rawClient->Exists(mutationId, transactionId, formatPath);
+ });
+ if (!exists) {
return TMaybe<TNode>();
}
- TMaybe<TNode> format = NDetail::NRawClient::Get(retryPolicy->CreatePolicyForGenericRequest(), context, transactionId, formatPath);
+
+ auto format = NDetail::RequestWithRetry<TMaybe<TNode>>(
+ retryPolicy->CreatePolicyForGenericRequest(),
+ [&rawClient, &transactionId, &formatPath] (TMutationId& mutationId) {
+ return rawClient->Get(mutationId, transactionId, formatPath);
+ });
if (format.Get()->AsString() != "yamred_dsv") {
return TMaybe<TNode>();
}
@@ -90,13 +102,13 @@ TMaybe<TNode> GetTableFormat(
TMaybe<TNode> GetTableFormats(
const IClientRetryPolicyPtr& clientRetryPolicy,
- const TClientContext& context,
+ const IRawClientPtr& rawClient,
const TTransactionId& transactionId,
const TVector<TRichYPath>& inputs)
{
TVector<TMaybe<TNode>> formats;
for (auto& table : inputs) {
- formats.push_back(GetTableFormat(clientRetryPolicy, context, transactionId, table));
+ formats.push_back(GetTableFormat(clientRetryPolicy, rawClient, transactionId, table));
}
return GetCommonTableFormat(formats);
@@ -310,11 +322,13 @@ struct TFormatBuilder::TFormatSwitcher
};
TFormatBuilder::TFormatBuilder(
+ IRawClientPtr rawClient,
IClientRetryPolicyPtr clientRetryPolicy,
TClientContext context,
TTransactionId transactionId,
TOperationOptions operationOptions)
- : ClientRetryPolicy_(std::move(clientRetryPolicy))
+ : RawClient_(std::move(rawClient))
+ , ClientRetryPolicy_(std::move(clientRetryPolicy))
, Context_(std::move(context))
, TransactionId_(transactionId)
, OperationOptions_(std::move(operationOptions))
@@ -376,7 +390,7 @@ std::pair<TFormat, TMaybe<TSmallJobFile>> TFormatBuilder::CreateYamrFormat(
Y_ABORT_UNLESS(table.RichYPath, "Cannot use format from table for intermediate table");
tableList.push_back(*table.RichYPath);
}
- formatFromTableAttributes = GetTableFormats(ClientRetryPolicy_, Context_, TransactionId_, tableList);
+ formatFromTableAttributes = GetTableFormats(ClientRetryPolicy_, RawClient_, TransactionId_, tableList);
}
if (formatFromTableAttributes) {
return {