diff options
author | hiddenpath <[email protected]> | 2025-04-18 06:14:31 +0300 |
---|---|---|
committer | hiddenpath <[email protected]> | 2025-04-18 06:26:19 +0300 |
commit | 794bfc553e78c09c6b275acbf5a71c62c722df1a (patch) | |
tree | 56fcdfce774fcba27c5f747ee8fbeff3966ee26b | |
parent | 7439a2bee2845a5b8a3b38c42b9cdd03ce6c9b2f (diff) |
YT-23616: Dispatch on some dyntable methods
commit_hash:c279c66b6d18c54f7f1794d2a0ba851119dd59c8
-rw-r--r-- | yt/cpp/mapreduce/client/client.cpp | 6 | ||||
-rw-r--r-- | yt/cpp/mapreduce/http_client/raw_client.cpp | 42 | ||||
-rw-r--r-- | yt/cpp/mapreduce/http_client/raw_requests.cpp | 63 | ||||
-rw-r--r-- | yt/cpp/mapreduce/http_client/raw_requests.h | 18 |
4 files changed, 42 insertions, 87 deletions
diff --git a/yt/cpp/mapreduce/client/client.cpp b/yt/cpp/mapreduce/client/client.cpp index 18c7a3ad5d4..c4bb54d1a7d 100644 --- a/yt/cpp/mapreduce/client/client.cpp +++ b/yt/cpp/mapreduce/client/client.cpp @@ -1226,7 +1226,7 @@ void TClient::InsertRows( RequestWithRetry<void>( ClientRetryPolicy_->CreatePolicyForGenericRequest(), [this, &path, &rows, &options] (TMutationId /*mutationId*/) { - NRawClient::InsertRows(Context_, path, rows, options); + RawClient_->InsertRows(path, rows, options); }); } @@ -1239,7 +1239,7 @@ void TClient::DeleteRows( RequestWithRetry<void>( ClientRetryPolicy_->CreatePolicyForGenericRequest(), [this, &path, &keys, &options] (TMutationId /*mutationId*/) { - NRawClient::DeleteRows(Context_, path, keys, options); + RawClient_->DeleteRows(path, keys, options); }); } @@ -1266,7 +1266,7 @@ TNode::TListType TClient::LookupRows( return RequestWithRetry<TNode::TListType>( ClientRetryPolicy_->CreatePolicyForGenericRequest(), [this, &path, &keys, &options] (TMutationId /*mutationId*/) { - return NRawClient::LookupRows(Context_, path, keys, options); + return RawClient_->LookupRows(path, keys, options); }); } diff --git a/yt/cpp/mapreduce/http_client/raw_client.cpp b/yt/cpp/mapreduce/http_client/raw_client.cpp index ab8fbf5821c..cb5a852b176 100644 --- a/yt/cpp/mapreduce/http_client/raw_client.cpp +++ b/yt/cpp/mapreduce/http_client/raw_client.cpp @@ -677,7 +677,14 @@ void THttpRawClient::InsertRows( const TNode::TListType& rows, const TInsertRowsOptions& options) { - NRawClient::InsertRows(Context_, path, rows, options); + TMutationId mutationId; + THttpHeader header("PUT", "insert_rows"); + header.SetInputFormat(TFormat::YsonBinary()); + header.MergeParameters(NRawClient::SerializeParametersForInsertRows(Context_.Config->Prefix, path, options)); + auto body = NodeListToYsonString(rows); + TRequestConfig config; + config.IsHeavy = true; + RequestWithoutRetry(Context_, mutationId, header, body, config)->GetResponse(); } void THttpRawClient::TrimRows( @@ -701,7 +708,28 @@ TNode::TListType THttpRawClient::LookupRows( const TNode::TListType& keys, const TLookupRowsOptions& options) { - return NRawClient::LookupRows(Context_, path, keys, options); + TMutationId mutationId; + THttpHeader header("PUT", "lookup_rows"); + header.AddPath(AddPathPrefix(path, Context_.Config->ApiVersion)); + header.SetInputFormat(TFormat::YsonBinary()); + header.SetOutputFormat(TFormat::YsonBinary()); + + header.MergeParameters(BuildYsonNodeFluently().BeginMap() + .DoIf(options.Timeout_.Defined(), [&] (TFluentMap fluent) { + fluent.Item("timeout").Value(static_cast<i64>(options.Timeout_->MilliSeconds())); + }) + .Item("keep_missing_rows").Value(options.KeepMissingRows_) + .Item("versioned").Value(options.Versioned_) + .DoIf(options.Columns_.Defined(), [&] (TFluentMap fluent) { + fluent.Item("column_names").Value(*options.Columns_); + }) + .EndMap()); + + auto body = NodeListToYsonString(keys); + TRequestConfig config; + config.IsHeavy = true; + auto responseInfo = RequestWithoutRetry(Context_, mutationId, header, body, config); + return NodeFromYsonString(responseInfo->GetResponse(), ::NYson::EYsonType::ListFragment).AsList(); } TNode::TListType THttpRawClient::SelectRows( @@ -819,7 +847,15 @@ void THttpRawClient::DeleteRows( const TNode::TListType& keys, const TDeleteRowsOptions& options) { - NRawClient::DeleteRows(Context_, path, keys, options); + TMutationId mutationId; + THttpHeader header("PUT", "delete_rows"); + header.SetInputFormat(TFormat::YsonBinary()); + header.MergeParameters(NRawClient::SerializeParametersForDeleteRows(Context_.Config->Prefix, path, options)); + + auto body = NodeListToYsonString(keys); + TRequestConfig config; + config.IsHeavy = true; + RequestWithoutRetry(Context_, mutationId, header, body, config)->GetResponse(); } void THttpRawClient::FreezeTable( diff --git a/yt/cpp/mapreduce/http_client/raw_requests.cpp b/yt/cpp/mapreduce/http_client/raw_requests.cpp index 5d19ea1fb9a..c07c5ac1ddd 100644 --- a/yt/cpp/mapreduce/http_client/raw_requests.cpp +++ b/yt/cpp/mapreduce/http_client/raw_requests.cpp @@ -356,69 +356,6 @@ std::unique_ptr<IOutputStream> WriteTable( return std::make_unique<THttpRequestStream>(std::move(request), options.BufferSize_); } -void InsertRows( - const TClientContext& context, - const TYPath& path, - const TNode::TListType& rows, - const TInsertRowsOptions& options) -{ - TMutationId mutationId; - THttpHeader header("PUT", "insert_rows"); - header.SetInputFormat(TFormat::YsonBinary()); - header.MergeParameters(NRawClient::SerializeParametersForInsertRows(context.Config->Prefix, path, options)); - auto body = NodeListToYsonString(rows); - TRequestConfig config; - config.IsHeavy = true; - RequestWithoutRetry(context, mutationId, header, body, config)->GetResponse(); -} - -TNode::TListType LookupRows( - const TClientContext& context, - const TYPath& path, - const TNode::TListType& keys, - const TLookupRowsOptions& options) -{ - TMutationId mutationId; - THttpHeader header("PUT", "lookup_rows"); - header.AddPath(AddPathPrefix(path, context.Config->ApiVersion)); - header.SetInputFormat(TFormat::YsonBinary()); - header.SetOutputFormat(TFormat::YsonBinary()); - - header.MergeParameters(BuildYsonNodeFluently().BeginMap() - .DoIf(options.Timeout_.Defined(), [&] (TFluentMap fluent) { - fluent.Item("timeout").Value(static_cast<i64>(options.Timeout_->MilliSeconds())); - }) - .Item("keep_missing_rows").Value(options.KeepMissingRows_) - .Item("versioned").Value(options.Versioned_) - .DoIf(options.Columns_.Defined(), [&] (TFluentMap fluent) { - fluent.Item("column_names").Value(*options.Columns_); - }) - .EndMap()); - - auto body = NodeListToYsonString(keys); - TRequestConfig config; - config.IsHeavy = true; - auto responseInfo = RequestWithoutRetry(context, mutationId, header, body, config); - return NodeFromYsonString(responseInfo->GetResponse(), ::NYson::EYsonType::ListFragment).AsList(); -} - -void DeleteRows( - const TClientContext& context, - const TYPath& path, - const TNode::TListType& keys, - const TDeleteRowsOptions& options) -{ - TMutationId mutationId; - THttpHeader header("PUT", "delete_rows"); - header.SetInputFormat(TFormat::YsonBinary()); - header.MergeParameters(NRawClient::SerializeParametersForDeleteRows(context.Config->Prefix, path, options)); - - auto body = NodeListToYsonString(keys); - TRequestConfig config; - config.IsHeavy = true; - RequestWithoutRetry(context, mutationId, header, body, config)->GetResponse(); -} - TAuthorizationInfo WhoAmI(const TClientContext& context) { TMutationId mutationId; diff --git a/yt/cpp/mapreduce/http_client/raw_requests.h b/yt/cpp/mapreduce/http_client/raw_requests.h index 41208ad2c0d..63f39f62bba 100644 --- a/yt/cpp/mapreduce/http_client/raw_requests.h +++ b/yt/cpp/mapreduce/http_client/raw_requests.h @@ -55,24 +55,6 @@ std::unique_ptr<IOutputStream> WriteTable( const TMaybe<TFormat>& format, const TTableWriterOptions& options); -void InsertRows( - const TClientContext& context, - const TYPath& path, - const TNode::TListType& rows, - const TInsertRowsOptions& options); - -TNode::TListType LookupRows( - const TClientContext& context, - const TYPath& path, - const TNode::TListType& keys, - const TLookupRowsOptions& options); - -void DeleteRows( - const TClientContext& context, - const TYPath& path, - const TNode::TListType& keys, - const TDeleteRowsOptions& options); - TAuthorizationInfo WhoAmI(const TClientContext& context); //////////////////////////////////////////////////////////////////////////////// |