Skip to content

Commit f29f617

Browse files
author
hiddenpath
committed
YT-23616: Temprorary fallback to http implementation for some methods
This commit should be reverted when these methods will have corresponding RPC implementations. ``` void TRpcRawClient::DeleteRows( const TYPath& /*path*/, const TNode::TListType& /*keys*/, const TDeleteRowsOptions& /*options*/) { YT_UNIMPLEMENTED(); } ``` commit_hash:a7957f365cc49dce53d44d702288a41cb2ec45b9
1 parent 7fed694 commit f29f617

File tree

4 files changed

+90
-44
lines changed

4 files changed

+90
-44
lines changed

yt/cpp/mapreduce/client/client.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ void TClient::InsertRows(
11781178
RequestWithRetry<void>(
11791179
ClientRetryPolicy_->CreatePolicyForGenericRequest(),
11801180
[this, &path, &rows, &options] (TMutationId /*mutationId*/) {
1181-
RawClient_->InsertRows(path, rows, options);
1181+
NRawClient::InsertRows(Context_, path, rows, options);
11821182
});
11831183
}
11841184

@@ -1191,7 +1191,7 @@ void TClient::DeleteRows(
11911191
RequestWithRetry<void>(
11921192
ClientRetryPolicy_->CreatePolicyForGenericRequest(),
11931193
[this, &path, &keys, &options] (TMutationId /*mutationId*/) {
1194-
RawClient_->DeleteRows(path, keys, options);
1194+
NRawClient::DeleteRows(Context_, path, keys, options);
11951195
});
11961196
}
11971197

@@ -1218,7 +1218,7 @@ TNode::TListType TClient::LookupRows(
12181218
return RequestWithRetry<TNode::TListType>(
12191219
ClientRetryPolicy_->CreatePolicyForGenericRequest(),
12201220
[this, &path, &keys, &options] (TMutationId /*mutationId*/) {
1221-
return RawClient_->LookupRows(path, keys, options);
1221+
return NRawClient::LookupRows(Context_, path, keys, options);
12221222
});
12231223
}
12241224

yt/cpp/mapreduce/http_client/raw_client.cpp

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -677,14 +677,7 @@ void THttpRawClient::InsertRows(
677677
const TNode::TListType& rows,
678678
const TInsertRowsOptions& options)
679679
{
680-
TMutationId mutationId;
681-
THttpHeader header("PUT", "insert_rows");
682-
header.SetInputFormat(TFormat::YsonBinary());
683-
header.MergeParameters(NRawClient::SerializeParametersForInsertRows(Context_.Config->Prefix, path, options));
684-
auto body = NodeListToYsonString(rows);
685-
TRequestConfig config;
686-
config.IsHeavy = true;
687-
RequestWithoutRetry(Context_, mutationId, header, body, config)->GetResponse();
680+
NRawClient::InsertRows(Context_, path, rows, options);
688681
}
689682

690683
void THttpRawClient::TrimRows(
@@ -708,30 +701,7 @@ TNode::TListType THttpRawClient::LookupRows(
708701
const TNode::TListType& keys,
709702
const TLookupRowsOptions& options)
710703
{
711-
TMutationId mutationId;
712-
THttpHeader header("PUT", "lookup_rows");
713-
header.AddPath(AddPathPrefix(path, Context_.Config->ApiVersion));
714-
header.SetInputFormat(TFormat::YsonBinary());
715-
header.SetOutputFormat(TFormat::YsonBinary());
716-
717-
header.MergeParameters(BuildYsonNodeFluently().BeginMap()
718-
.DoIf(options.Timeout_.Defined(), [&] (TFluentMap fluent) {
719-
fluent.Item("timeout").Value(static_cast<i64>(options.Timeout_->MilliSeconds()));
720-
})
721-
.Item("keep_missing_rows").Value(options.KeepMissingRows_)
722-
.DoIf(options.Versioned_.Defined(), [&] (TFluentMap fluent) {
723-
fluent.Item("versioned").Value(*options.Versioned_);
724-
})
725-
.DoIf(options.Columns_.Defined(), [&] (TFluentMap fluent) {
726-
fluent.Item("column_names").Value(*options.Columns_);
727-
})
728-
.EndMap());
729-
730-
auto body = NodeListToYsonString(keys);
731-
TRequestConfig config;
732-
config.IsHeavy = true;
733-
auto responseInfo = RequestWithoutRetry(Context_, mutationId, header, body, config);
734-
return NodeFromYsonString(responseInfo->GetResponse(), ::NYson::EYsonType::ListFragment).AsList();
704+
return NRawClient::LookupRows(Context_, path, keys, options);
735705
}
736706

737707
TNode::TListType THttpRawClient::SelectRows(
@@ -831,15 +801,7 @@ void THttpRawClient::DeleteRows(
831801
const TNode::TListType& keys,
832802
const TDeleteRowsOptions& options)
833803
{
834-
TMutationId mutationId;
835-
THttpHeader header("PUT", "delete_rows");
836-
header.SetInputFormat(TFormat::YsonBinary());
837-
header.MergeParameters(NRawClient::SerializeParametersForDeleteRows(Context_.Config->Prefix, path, options));
838-
839-
auto body = NodeListToYsonString(keys);
840-
TRequestConfig config;
841-
config.IsHeavy = true;
842-
RequestWithoutRetry(Context_, mutationId, header, body, config)->GetResponse();
804+
NRawClient::DeleteRows(Context_, path, keys, options);
843805
}
844806

845807
void THttpRawClient::FreezeTable(

yt/cpp/mapreduce/http_client/raw_requests.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <yt/cpp/mapreduce/interface/config.h>
1717
#include <yt/cpp/mapreduce/interface/client.h>
18+
#include <yt/cpp/mapreduce/interface/fluent.h>
1819
#include <yt/cpp/mapreduce/interface/operation.h>
1920
#include <yt/cpp/mapreduce/interface/serialize.h>
2021
#include <yt/cpp/mapreduce/interface/tvm.h>
@@ -308,6 +309,71 @@ NHttpClient::IHttpResponsePtr SkyShareTable(
308309
return RequestWithoutRetry(skyApiHost, mutationId, header, "");
309310
}
310311

312+
void InsertRows(
313+
const TClientContext& context,
314+
const TYPath& path,
315+
const TNode::TListType& rows,
316+
const TInsertRowsOptions& options)
317+
{
318+
TMutationId mutationId;
319+
THttpHeader header("PUT", "insert_rows");
320+
header.SetInputFormat(TFormat::YsonBinary());
321+
header.MergeParameters(NRawClient::SerializeParametersForInsertRows(context.Config->Prefix, path, options));
322+
auto body = NodeListToYsonString(rows);
323+
TRequestConfig config;
324+
config.IsHeavy = true;
325+
RequestWithoutRetry(context, mutationId, header, body, config)->GetResponse();
326+
}
327+
328+
TNode::TListType LookupRows(
329+
const TClientContext& context,
330+
const TYPath& path,
331+
const TNode::TListType& keys,
332+
const TLookupRowsOptions& options)
333+
{
334+
TMutationId mutationId;
335+
THttpHeader header("PUT", "lookup_rows");
336+
header.AddPath(AddPathPrefix(path, context.Config->ApiVersion));
337+
header.SetInputFormat(TFormat::YsonBinary());
338+
header.SetOutputFormat(TFormat::YsonBinary());
339+
340+
header.MergeParameters(BuildYsonNodeFluently().BeginMap()
341+
.DoIf(options.Timeout_.Defined(), [&] (TFluentMap fluent) {
342+
fluent.Item("timeout").Value(static_cast<i64>(options.Timeout_->MilliSeconds()));
343+
})
344+
.Item("keep_missing_rows").Value(options.KeepMissingRows_)
345+
.DoIf(options.Versioned_.Defined(), [&] (TFluentMap fluent) {
346+
fluent.Item("versioned").Value(*options.Versioned_);
347+
})
348+
.DoIf(options.Columns_.Defined(), [&] (TFluentMap fluent) {
349+
fluent.Item("column_names").Value(*options.Columns_);
350+
})
351+
.EndMap());
352+
353+
auto body = NodeListToYsonString(keys);
354+
TRequestConfig config;
355+
config.IsHeavy = true;
356+
auto responseInfo = RequestWithoutRetry(context, mutationId, header, body, config);
357+
return NodeFromYsonString(responseInfo->GetResponse(), ::NYson::EYsonType::ListFragment).AsList();
358+
}
359+
360+
void DeleteRows(
361+
const TClientContext& context,
362+
const TYPath& path,
363+
const TNode::TListType& keys,
364+
const TDeleteRowsOptions& options)
365+
{
366+
TMutationId mutationId;
367+
THttpHeader header("PUT", "delete_rows");
368+
header.SetInputFormat(TFormat::YsonBinary());
369+
header.MergeParameters(NRawClient::SerializeParametersForDeleteRows(context.Config->Prefix, path, options));
370+
371+
auto body = NodeListToYsonString(keys);
372+
TRequestConfig config;
373+
config.IsHeavy = true;
374+
RequestWithoutRetry(context, mutationId, header, body, config)->GetResponse();
375+
}
376+
311377
TAuthorizationInfo WhoAmI(const TClientContext& context)
312378
{
313379
TMutationId mutationId;

yt/cpp/mapreduce/http_client/raw_requests.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ NHttpClient::IHttpResponsePtr SkyShareTable(
4646
const std::vector<TYPath>& tablePaths,
4747
const TSkyShareTableOptions& options);
4848

49+
void InsertRows(
50+
const TClientContext& context,
51+
const TYPath& path,
52+
const TNode::TListType& rows,
53+
const TInsertRowsOptions& options);
54+
55+
TNode::TListType LookupRows(
56+
const TClientContext& context,
57+
const TYPath& path,
58+
const TNode::TListType& keys,
59+
const TLookupRowsOptions& options);
60+
61+
void DeleteRows(
62+
const TClientContext& context,
63+
const TYPath& path,
64+
const TNode::TListType& keys,
65+
const TDeleteRowsOptions& options);
66+
4967
TAuthorizationInfo WhoAmI(const TClientContext& context);
5068

5169
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)