Skip to content

Commit 9f3244b

Browse files
fix after review
1 parent 16b6d5d commit 9f3244b

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

tests/integration/bulk_upsert_simple_it/bulk_upsert.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,16 @@ TRunArgs GetRunArgs() {
3838
}
3939

4040
TStatus CreateTable(TTableClient& client, const std::string& table) {
41-
std::cerr << "Create table " << table << "\n";
42-
4341
TRetryOperationSettings settings;
4442
auto status = client.RetryOperationSync([&table](TSession session) {
4543
auto tableDesc = TTableBuilder()
46-
.AddNonNullableColumn("pk", EPrimitiveType::Uint64)
4744
.AddNullableColumn("App", EPrimitiveType::Utf8)
4845
.AddNullableColumn("Timestamp", EPrimitiveType::Timestamp)
4946
.AddNullableColumn("Host", EPrimitiveType::Utf8)
47+
.AddNonNullableColumn("Id", EPrimitiveType::Uint64)
5048
.AddNullableColumn("HttpCode", EPrimitiveType::Uint32)
5149
.AddNullableColumn("Message", EPrimitiveType::Utf8)
52-
.SetPrimaryKeyColumns({"pk"})
50+
.SetPrimaryKeyColumns({"App", "Timestamp", "Host", "Id"})
5351
.Build();
5452

5553
return session.CreateTable(table, std::move(tableDesc)).GetValueSync();
@@ -66,10 +64,10 @@ TStatistic GetLogBatch(uint64_t logOffset, std::vector<TLogMessage>& logBatch, u
6664

6765
for (size_t i = 0; i < BATCH_SIZE; ++i) {
6866
TLogMessage message;
69-
message.pk = correctRowCount + lastNumber;
70-
message.App = "App_" + std::to_string(logOffset % 10);
71-
message.Host = "192.168.0." + std::to_string(logOffset % 11);
72-
message.Timestamp = TInstant::Now() + TDuration::MilliSeconds(i % 1000);
67+
message.Pk.Id = correctRowCount + lastNumber;
68+
message.Pk.App = "App_" + std::to_string(logOffset % 10);
69+
message.Pk.Host = "192.168.0." + std::to_string(logOffset % 11);
70+
message.Pk.Timestamp = TInstant::Now() + TDuration::MilliSeconds(i % 1000);
7371
message.HttpCode = 200;
7472
message.Message = i % 2 ? "GET / HTTP/1.1" : "GET /images/logo.png HTTP/1.1";
7573
logBatch.emplace_back(message);
@@ -89,10 +87,10 @@ TStatus WriteLogBatch(TTableClient& tableClient, const std::string& table, const
8987
for (const auto& message : logBatch) {
9088
rows.AddListItem()
9189
.BeginStruct()
92-
.AddMember("pk").Uint64(message.pk)
93-
.AddMember("App").Utf8(message.App)
94-
.AddMember("Host").Utf8(message.Host)
95-
.AddMember("Timestamp").Timestamp(message.Timestamp)
90+
.AddMember("Id").Uint64(message.Pk.Id)
91+
.AddMember("App").Utf8(message.Pk.App)
92+
.AddMember("Host").Utf8(message.Pk.Host)
93+
.AddMember("Timestamp").Timestamp(message.Pk.Timestamp)
9694
.AddMember("HttpCode").Uint32(message.HttpCode)
9795
.AddMember("Message").Utf8(message.Message)
9896
.EndStruct();
@@ -147,7 +145,6 @@ TStatistic Select(TTableClient& client, const std::string& path) {
147145
uint64_t rowCount = 0;
148146

149147
if (parser.TryNextRow()) {
150-
151148
sumApp = *parser.ColumnParser("column0").GetOptionalInt64();
152149
sumHost = *parser.ColumnParser("column1").GetOptionalInt64();
153150
rowCount = parser.ColumnParser("column2").GetUint64();

tests/integration/bulk_upsert_simple_it/bulk_upsert.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ using namespace NYdb;
77
using namespace NYdb::NTable;
88

99
struct TRunArgs {
10-
TDriver driver;
11-
std::string path;
10+
TDriver Driver;
11+
std::string Path;
1212
};
1313

1414
struct TLogMessage {
15-
uint64_t pk;
16-
std::string App;
17-
std::string Host;
18-
TInstant Timestamp;
15+
struct TPrimaryKeyLogMessage {
16+
std::string App;
17+
std::string Host;
18+
TInstant Timestamp;
19+
uint64_t Id;
20+
bool operator<(const TPrimaryKeyLogMessage& o) const;
21+
};
22+
23+
TPrimaryKeyLogMessage Pk;
1924
uint32_t HttpCode;
2025
std::string Message;
2126
};
@@ -29,9 +34,9 @@ class TYdbErrorException : public yexception {
2934
};
3035

3136
struct TStatistic {
32-
uint64_t sumApp;
33-
uint64_t sumHost;
34-
uint64_t rowCount;
37+
uint64_t SumApp;
38+
uint64_t SumHost;
39+
uint64_t RowCount;
3540
};
3641

3742
TRunArgs GetRunArgs();

0 commit comments

Comments
 (0)