Skip to content

Commit 6cdb675

Browse files
stanislav-shchetininGazizonoki
authored andcommitted
return containers
1 parent 8637e85 commit 6cdb675

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

tests/integration/sessions_it/sessions_it.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
2525
NYdb::NTable::TTableClient client(driver);
2626
int count = 10;
2727

28-
std::unordered_set<std::string> sids;
28+
THashSet<std::string> sids;
2929
while (count--) {
3030
auto sessionResponse = client.GetSession().ExtractValueSync();
3131
UNIT_ASSERT_EQUAL(sessionResponse.IsTransportError(), false);
@@ -55,8 +55,8 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
5555
NYdb::NTable::TTableClient client(driver);
5656
int count = 10;
5757

58-
std::vector<TSession> sids;
59-
std::vector<TAsyncDataQueryResult> results;
58+
TVector<TSession> sids;
59+
TVector<TAsyncDataQueryResult> results;
6060
while (count--) {
6161
auto sessionResponse = client.GetSession().ExtractValueSync();
6262
UNIT_ASSERT_EQUAL(sessionResponse.IsTransportError(), false);
@@ -90,8 +90,8 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
9090
NYdb::NTable::TTableClient client(driver);
9191
int count = 10;
9292

93-
std::vector<TSession> sids;
94-
std::vector<TAsyncDataQueryResult> results;
93+
TVector<TSession> sids;
94+
TVector<TAsyncDataQueryResult> results;
9595
while (count--) {
9696
auto sessionResponse = client.GetSession().ExtractValueSync();
9797
UNIT_ASSERT_EQUAL(sessionResponse.IsTransportError(), false);
@@ -189,7 +189,7 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
189189
};
190190
IThreadFactory* pool = SystemThreadFactory();
191191

192-
std::vector<TAutoPtr<IThreadFactory::IThread>> threads;
192+
TVector<TAutoPtr<IThreadFactory::IThread>> threads;
193193
threads.resize(nThreads);
194194
for (int i = 0; i < nThreads; i++) {
195195
threads[i] = pool->Run(job);
@@ -229,12 +229,12 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
229229

230230
constexpr int nThreads = 100;
231231
NYdb::EStatus statuses[nThreads];
232-
std::vector<std::optional<typename TClient::TSession>> sessions;
232+
TVector<TMaybe<typename TClient::TSession>> sessions;
233233
sessions.resize(nThreads);
234-
std::atomic<int> t = 0;
234+
TAtomic t = 0;
235235
auto job = [client, &t, &statuses, &sessions]() mutable {
236236
auto sessionResponse = client.GetSession().ExtractValueSync();
237-
int i = ++t;
237+
int i = AtomicIncrement(t);
238238
statuses[--i] = sessionResponse.GetStatus();
239239
if (statuses[i] == EStatus::SUCCESS) {
240240
EnsureCanExecQuery(sessionResponse.GetSession());
@@ -243,7 +243,7 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
243243
};
244244
IThreadFactory* pool = SystemThreadFactory();
245245

246-
std::vector<TAutoPtr<IThreadFactory::IThread>> threads;
246+
TVector<TAutoPtr<IThreadFactory::IThread>> threads;
247247
threads.resize(nThreads);
248248
for (int i = 0; i < nThreads; i++) {
249249
threads[i] = pool->Run(job);
@@ -309,14 +309,14 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
309309

310310
constexpr int nThreads = 20;
311311
constexpr int nRequests = 50;
312-
std::array<std::vector<typename T::TResult>, nThreads> results;
312+
std::array<TVector<typename T::TResult>, nThreads> results;
313313
std::atomic<int> t = 0;
314314
std::atomic<int> validSessions = 0;
315315
auto job = [client, &t, &results, &validSessions]() mutable {
316316
auto sessionResponse = client.GetSession().ExtractValueSync();
317317

318318
int i = ++t;
319-
std::vector<typename T::TResult>& r = results[--i];
319+
TVector<typename T::TResult>& r = results[--i];
320320

321321
if (sessionResponse.GetStatus() != EStatus::SUCCESS) {
322322
return;
@@ -329,7 +329,7 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
329329
};
330330
IThreadFactory* pool = SystemThreadFactory();
331331

332-
std::vector<TAutoPtr<IThreadFactory::IThread>> threads;
332+
TVector<TAutoPtr<IThreadFactory::IThread>> threads;
333333
threads.resize(nThreads);
334334
for (int i = 0; i < nThreads; i++) {
335335
threads[i] = pool->Run(job);
@@ -475,7 +475,7 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
475475
}*/
476476

477477
Y_UNIT_TEST(CloseSessionAfterDriverDtorWithoutSessionPool) {
478-
std::vector<std::string> sessionIds;
478+
TVector<std::string> sessionIds;
479479
int iterations = 50;
480480

481481
while (iterations--) {
@@ -505,7 +505,7 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
505505
}
506506

507507
Y_UNIT_TEST(CloseSessionWithSessionPoolExplicit) {
508-
std::vector<std::string> sessionIds;
508+
TVector<std::string> sessionIds;
509509
int iterations = 100;
510510

511511
while (iterations--) {
@@ -559,7 +559,7 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
559559
}
560560

561561
Y_UNIT_TEST(CloseSessionWithSessionPoolExplicitDriverStopOnly) {
562-
std::vector<std::string> sessionIds;
562+
TVector<std::string> sessionIds;
563563
int iterations = 100;
564564

565565
while (iterations--) {
@@ -601,7 +601,7 @@ Y_UNIT_TEST_SUITE(YdbSdkSessions) {
601601
}
602602

603603
Y_UNIT_TEST(CloseSessionWithSessionPoolFromDtors) {
604-
std::vector<std::string> sessionIds;
604+
TVector<std::string> sessionIds;
605605
int iterations = 100;
606606

607607
while (iterations--) {

tests/integration/sessions_pool_it/sessions_pool_it.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ using TPlan = std::vector<std::pair<EAction, ui32>>;
5454

5555

5656
void CheckPlan(TPlan plan) {
57-
std::unordered_map<ui32, EAction> sessions;
57+
THashMap<ui32, EAction> sessions;
5858
for (const auto& [action, sessionId]: plan) {
5959
if (action == EAction::CreateFuture) {
6060
UNIT_ASSERT(!sessions.contains(sessionId));
@@ -79,8 +79,8 @@ void CheckPlan(TPlan plan) {
7979
}
8080

8181
void RunPlan(const TPlan& plan, NYdb::NTable::TTableClient& client) {
82-
std::unordered_map<ui32, NThreading::TFuture<NYdb::NTable::TCreateSessionResult>> sessionFutures;
83-
std::unordered_map<ui32, NYdb::NTable::TCreateSessionResult> sessions;
82+
THashMap<ui32, NThreading::TFuture<NYdb::NTable::TCreateSessionResult>> sessionFutures;
83+
THashMap<ui32, NYdb::NTable::TCreateSessionResult> sessions;
8484

8585
ui32 requestedSessions = 0;
8686

@@ -162,8 +162,8 @@ Y_UNIT_TEST_SUITE(YdbSdkSessionsPool) {
162162
}
163163

164164
void TestWaitQueue(NYdb::NTable::TTableClient& client, ui32 activeSessionsLimit) {
165-
std::vector<NThreading::TFuture<NYdb::NTable::TCreateSessionResult>> sessionFutures;
166-
std::vector<NYdb::NTable::TCreateSessionResult> sessions;
165+
TVector<NThreading::TFuture<NYdb::NTable::TCreateSessionResult>> sessionFutures;
166+
TVector<NYdb::NTable::TCreateSessionResult> sessions;
167167

168168
// exhaust the pool
169169
for (ui32 i = 0; i < activeSessionsLimit; ++i) {
@@ -248,8 +248,8 @@ Y_UNIT_TEST_SUITE(YdbSdkSessionsPool) {
248248
}
249249

250250
ui32 RunStressTestSync(ui32 n, ui32 activeSessionsLimit, NYdb::NTable::TTableClient& client) {
251-
std::vector<NThreading::TFuture<NYdb::NTable::TCreateSessionResult>> sessionFutures;
252-
std::vector<NYdb::NTable::TCreateSessionResult> sessions;
251+
TVector<NThreading::TFuture<NYdb::NTable::TCreateSessionResult>> sessionFutures;
252+
TVector<NYdb::NTable::TCreateSessionResult> sessions;
253253
std::mt19937 rng(0);
254254
ui32 successCount = 0;
255255

@@ -338,7 +338,7 @@ Y_UNIT_TEST_SUITE(YdbSdkSessionsPool) {
338338
};
339339

340340
IThreadFactory* pool = SystemThreadFactory();
341-
std::vector<TAutoPtr<IThreadFactory::IThread>> threads;
341+
TVector<TAutoPtr<IThreadFactory::IThread>> threads;
342342
threads.resize(nThreads);
343343
for (ui32 i = 0; i < nThreads; i++) {
344344
threads[i] = pool->Run(job);
@@ -379,8 +379,8 @@ Y_UNIT_TEST_SUITE(YdbSdkSessionsPool) {
379379
}
380380

381381
void TestPeriodicTask(ui32 activeSessionsLimit, NYdb::NTable::TTableClient& client) {
382-
std::vector<NThreading::TFuture<NYdb::NTable::TCreateSessionResult>> sessionFutures;
383-
std::vector<NYdb::NTable::TCreateSessionResult> sessions;
382+
TVector<NThreading::TFuture<NYdb::NTable::TCreateSessionResult>> sessionFutures;
383+
TVector<NYdb::NTable::TCreateSessionResult> sessions;
384384

385385
for (ui32 i = 0; i < activeSessionsLimit; ++i) {
386386
sessions.emplace_back(client.GetSession().ExtractValueSync());

0 commit comments

Comments
 (0)