Skip to content

Commit a2f7031

Browse files
pnv1github-actions[bot]
authored andcommitted
Move type in BulkUpsert conditionally, independent of value (#25673)
1 parent ffbee98 commit a2f7031

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

.github/last_commit.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ccb159ff5e6a49d325f2342fea08f07e9bd30a83
1+
7a9abfb04d596ae64b42a4c2af5d196b0c9f57fb

include/ydb-cpp-sdk/client/value/value.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@ namespace NYdb::inline V3 {
1818

1919
class TResultSetParser;
2020

21+
// Forward declarations for friend access
22+
namespace NTable {
23+
24+
class TTableClient;
25+
26+
} // namespace NTable
27+
2128
//! Representation of YDB type.
2229
class TType {
2330
friend class TProtoAccessor;
31+
friend class NTable::TTableClient;
2432
public:
2533
TType(const Ydb::Type& typeProto);
2634
TType(Ydb::Type&& typeProto);
@@ -264,12 +272,6 @@ struct TUuidValue {
264272
} Buf_;
265273
};
266274

267-
namespace NTable {
268-
269-
class TTableClient;
270-
271-
} // namespace NTable
272-
273275
//! Representation of YDB value.
274276
class TValue {
275277
friend class TValueParser;

src/client/table/impl/table_client.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ void TTableClient::TImpl::SetStatCollector(const NSdkStats::TStatCollector::TCli
10191019
SessionRemovedDueBalancing.Set(collector.SessionRemovedDueBalancing);
10201020
}
10211021

1022-
TAsyncBulkUpsertResult TTableClient::TImpl::BulkUpsert(const std::string& table, TValue&& rows, const TBulkUpsertSettings& settings, bool canMove) {
1022+
TAsyncBulkUpsertResult TTableClient::TImpl::BulkUpsert(const std::string& table, TValue&& rows, const TBulkUpsertSettings& settings) {
10231023
Ydb::Table::BulkUpsertRequest* request = nullptr;
10241024
std::unique_ptr<Ydb::Table::BulkUpsertRequest> holder;
10251025

@@ -1031,11 +1031,16 @@ TAsyncBulkUpsertResult TTableClient::TImpl::BulkUpsert(const std::string& table,
10311031
}
10321032

10331033
request->set_table(TStringType{table});
1034-
if (canMove) {
1034+
1035+
if (rows.GetType().Impl_.use_count() == 1) {
10351036
request->mutable_rows()->mutable_type()->Swap(&rows.GetType().GetProto());
1037+
} else {
1038+
*request->mutable_rows()->mutable_type() = rows.GetType().GetProto();
1039+
}
1040+
1041+
if (rows.Impl_.use_count() == 1) {
10361042
request->mutable_rows()->mutable_value()->Swap(&rows.GetProto());
10371043
} else {
1038-
*request->mutable_rows()->mutable_type() = TProtoAccessor::GetProto(rows.GetType());
10391044
*request->mutable_rows()->mutable_value() = rows.GetProto();
10401045
}
10411046

src/client/table/impl/table_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class TTableClient::TImpl: public TClientImplCommon<TTableClient::TImpl>, public
139139

140140
void SetStatCollector(const NSdkStats::TStatCollector::TClientStatCollector& collector);
141141

142-
TAsyncBulkUpsertResult BulkUpsert(const std::string& table, TValue&& rows, const TBulkUpsertSettings& settings, bool canMove);
142+
TAsyncBulkUpsertResult BulkUpsert(const std::string& table, TValue&& rows, const TBulkUpsertSettings& settings);
143143
TAsyncBulkUpsertResult BulkUpsert(const std::string& table, EDataFormat format,
144144
const std::string& data, const std::string& schema, const TBulkUpsertSettings& settings);
145145

src/client/table/table.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ NThreading::TFuture<void> TTableClient::Stop() {
14961496
TAsyncBulkUpsertResult TTableClient::BulkUpsert(const std::string& table, TValue&& rows,
14971497
const TBulkUpsertSettings& settings)
14981498
{
1499-
return Impl_->BulkUpsert(table, std::move(rows), settings, rows.Impl_.use_count() == 1);
1499+
return Impl_->BulkUpsert(table, std::move(rows), settings);
15001500
}
15011501

15021502
TAsyncBulkUpsertResult TTableClient::BulkUpsert(const std::string& table, EDataFormat format,

0 commit comments

Comments
 (0)