Skip to content

Commit

Permalink
Merge pull request #13 from ydb-platform/Replace-TVector-to-std_vector
Browse files Browse the repository at this point in the history
Replaced TVector with std::vector
  • Loading branch information
tkorsi authored Jan 26, 2024
2 parents 61af924 + 6c29d14 commit b5a1b59
Show file tree
Hide file tree
Showing 322 changed files with 1,346 additions and 1,340 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ util/all_util.cpp
util/charset/all_charset.cpp

cmake-build-debug
llvm.sh
12 changes: 6 additions & 6 deletions client/draft/ydb_dynamic_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon<TDynamicConfigClien
TRpcRequestSettings::Make(settings));
}

TAsyncStatus RemoveVolatileConfig(const TString& cluster, ui64 version, const TVector<ui64>& ids, const TClusterConfigSettings& settings = {}) {
TAsyncStatus RemoveVolatileConfig(const TString& cluster, ui64 version, const std::vector<ui64>& ids, const TClusterConfigSettings& settings = {}) {
auto request = MakeOperationRequest<Ydb::DynamicConfig::RemoveVolatileConfigRequest>(settings);

request.mutable_identity()->set_cluster(cluster);
Expand Down Expand Up @@ -87,7 +87,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon<TDynamicConfigClien
TRpcRequestSettings::Make(settings));
}

TAsyncStatus ForceRemoveVolatileConfig(const TVector<ui64>& ids, const TClusterConfigSettings& settings = {}) {
TAsyncStatus ForceRemoveVolatileConfig(const std::vector<ui64>& ids, const TClusterConfigSettings& settings = {}) {
auto request = MakeOperationRequest<Ydb::DynamicConfig::RemoveVolatileConfigRequest>(settings);

for (auto& id: ids) {
Expand Down Expand Up @@ -308,9 +308,9 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon<TDynamicConfigClien

if (Ydb::DynamicConfig::ResolveAllConfigResult result; any && any->UnpackTo(&result)) {
for (auto& config : result.configs()) {
TSet<TVector<TVerboseResolveConfigResult::TLabel>> labelSets;
TSet<std::vector<TVerboseResolveConfigResult::TLabel>> labelSets;
for (auto& labelSet : config.label_sets()) {
TVector<TVerboseResolveConfigResult::TLabel> set;
std::vector<TVerboseResolveConfigResult::TLabel> set;
for (auto& label : labelSet.labels()) {
labels.insert(label.label());
set.push_back(TVerboseResolveConfigResult::TLabel{convert(label.type()), label.value()});
Expand Down Expand Up @@ -373,7 +373,7 @@ TAsyncStatus TDynamicConfigClient::AddVolatileConfig(
TAsyncStatus TDynamicConfigClient::RemoveVolatileConfig(
const TString& cluster,
ui64 version,
const TVector<ui64>& ids,
const std::vector<ui64>& ids,
const TClusterConfigSettings& settings) {
return Impl_->RemoveVolatileConfig(cluster, version, ids, settings);
}
Expand All @@ -386,7 +386,7 @@ TAsyncStatus TDynamicConfigClient::RemoveAllVolatileConfigs(
}

TAsyncStatus TDynamicConfigClient::ForceRemoveVolatileConfig(
const TVector<ui64>& ids,
const std::vector<ui64>& ids,
const TClusterConfigSettings& settings) {
return Impl_->ForceRemoveVolatileConfig(ids, settings);
}
Expand Down
6 changes: 3 additions & 3 deletions client/draft/ydb_dynamic_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct TVerboseResolveConfigResult : public TStatus {
}
};

using ConfigByLabelSet = TMap<TSet<TVector<TLabel>>, TString>;
using ConfigByLabelSet = TMap<TSet<std::vector<TLabel>>, TString>;

TVerboseResolveConfigResult(
TStatus&& status,
Expand Down Expand Up @@ -200,7 +200,7 @@ class TDynamicConfigClient {
TAsyncStatus RemoveVolatileConfig(
const TString& cluster,
ui64 version,
const TVector<ui64>& ids,
const std::vector<ui64>& ids,
const TClusterConfigSettings& settings = {});

// Remove all volatile config
Expand All @@ -211,7 +211,7 @@ class TDynamicConfigClient {

// Remove specific volatile configs
TAsyncStatus ForceRemoveVolatileConfig(
const TVector<ui64>& ids,
const std::vector<ui64>& ids,
const TClusterConfigSettings& settings = {});

// Remove all volatile config
Expand Down
6 changes: 3 additions & 3 deletions client/draft/ydb_scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ namespace NScripting {

using namespace NThreading;

TExecuteYqlResult::TExecuteYqlResult(TStatus&& status, TVector<TResultSet>&& resultSets,
TExecuteYqlResult::TExecuteYqlResult(TStatus&& status, std::vector<TResultSet>&& resultSets,
const TMaybe<NTable::TQueryStats>& queryStats)
: TStatus(std::move(status))
, ResultSets_(std::move(resultSets))
, QueryStats_(queryStats) {}

const TVector<TResultSet>& TExecuteYqlResult::GetResultSets() const {
const std::vector<TResultSet>& TExecuteYqlResult::GetResultSets() const {
return ResultSets_;
}

Expand Down Expand Up @@ -163,7 +163,7 @@ class TScriptingClient::TImpl : public TClientImplCommon<TScriptingClient::TImpl

auto extractor = [promise]
(google::protobuf::Any* any, TPlainStatus status) mutable {
TVector<TResultSet> res;
std::vector<TResultSet> res;
TMaybe<NTable::TQueryStats> queryStats;
if (any) {
Ydb::Scripting::ExecuteYqlResult result;
Expand Down
6 changes: 3 additions & 3 deletions client/draft/ydb_scripting.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ namespace NScripting {

class TExecuteYqlResult : public TStatus {
public:
TExecuteYqlResult(TStatus&& status, TVector<TResultSet>&& resultSets,
TExecuteYqlResult(TStatus&& status, std::vector<TResultSet>&& resultSets,
const TMaybe<NTable::TQueryStats>& queryStats);

const TVector<TResultSet>& GetResultSets() const;
const std::vector<TResultSet>& GetResultSets() const;
TResultSet GetResultSet(size_t resultIndex) const;

TResultSetParser GetResultSetParser(size_t resultIndex) const;

const TMaybe<NTable::TQueryStats>& GetStats() const;

private:
TVector<TResultSet> ResultSets_;
std::vector<TResultSet> ResultSets_;
TMaybe<NTable::TQueryStats> QueryStats_;
};

Expand Down
2 changes: 1 addition & 1 deletion client/extensions/solomon_stats/pull_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TSolomonStatPullExtension::TParams::TParams(const TString& host
, const TString& project
, const TString& service
, const TString& cluster
, const TVector<std::pair<TString, TString>>& labels)
, const std::vector<std::pair<TString, TString>>& labels)
: Host_(host), Port_(port), Labels_()
{
Labels_.Add("project", project);
Expand Down
4 changes: 1 addition & 3 deletions client/extensions/solomon_stats/pull_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <library/cpp/monlib/service/pages/mon_page.h>
#include <library/cpp/monlib/service/monservice.h>

#include <util/generic/vector.h>

namespace NSolomonStatExtension {

class TSolomonStatPullExtension: public NYdb::IExtension {
Expand All @@ -26,7 +24,7 @@ class TSolomonStatPullExtension: public NYdb::IExtension {
, const TString& project
, const TString& service
, const TString& cluster
, const TVector<std::pair<TString, TString>>& labels = {});
, const std::vector<std::pair<TString, TString>>& labels = {});

NMonitoring::TLabels GetLabels() const;

Expand Down
28 changes: 14 additions & 14 deletions client/impl/ydb_endpoints/endpoints_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class TDiscoveryEmulator : public TThread {
void Exec() {
for (ui64 i = 0; i < MaxEvents_; i++) {
ui8 mask = RandomNumber<ui8>(16);
TVector<TEndpointRecord> endpoints;
std::vector<TEndpointRecord> endpoints;

for (size_t i = 0; i < Pool_.size(); i++) {
if (mask & (1 << i))
Expand All @@ -76,7 +76,7 @@ class TDiscoveryEmulator : public TThread {
Finished_.store(true);
}

const TVector<TEndpointRecord>& GetPool() const {
const std::vector<TEndpointRecord>& GetPool() const {
return Pool_;
}

Expand All @@ -89,10 +89,10 @@ class TDiscoveryEmulator : public TThread {
ui64 MaxEvents_;
std::atomic_bool Finished_;

static const TVector<TEndpointRecord> Pool_;
static const std::vector<TEndpointRecord> Pool_;
};

const TVector<TEndpointRecord> TDiscoveryEmulator::Pool_ = TVector<TEndpointRecord>{{"One", 1}, {"Two", 2}, {"Three", 3}, {"Four", 4}};
const std::vector<TEndpointRecord> TDiscoveryEmulator::Pool_ = std::vector<TEndpointRecord>{{"One", 1}, {"Two", 2}, {"Three", 3}, {"Four", 4}};

Y_UNIT_TEST_SUITE(CheckUtils) {

Expand All @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) {

Y_UNIT_TEST(GetEndpoint) {
TEndpointElectorSafe elector;
elector.SetNewState(TVector<TEndpointRecord>{{"Two", 0, "", 2}, {"One", 0, "", 1}});
elector.SetNewState(std::vector<TEndpointRecord>{{"Two", 0, "", 2}, {"One", 0, "", 1}});
UNIT_ASSERT_VALUES_EQUAL(elector.GetEndpoint(TEndpointKey("One", 0), true).Endpoint, "One");
UNIT_ASSERT_VALUES_EQUAL(elector.GetEndpoint(TEndpointKey("Two", 0), true).Endpoint, "Two");
UNIT_ASSERT_VALUES_EQUAL(elector.GetEndpoint(TEndpointKey("", 1), true).NodeId, 1);
Expand All @@ -127,26 +127,26 @@ Y_UNIT_TEST_SUITE(EndpointElector) {

Y_UNIT_TEST(DiffOnRemove) {
TEndpointElectorSafe elector;
auto removed = elector.SetNewState(TVector<TEndpointRecord>{{"Two", 2}, {"One", 1}});
auto removed = elector.SetNewState(std::vector<TEndpointRecord>{{"Two", 2}, {"One", 1}});
UNIT_ASSERT_VALUES_EQUAL(removed.size(), 0);
removed = elector.SetNewState(TVector<TEndpointRecord>{{"One", 1}});
removed = elector.SetNewState(std::vector<TEndpointRecord>{{"One", 1}});
UNIT_ASSERT_VALUES_EQUAL(removed.size(), 1);
UNIT_ASSERT_VALUES_EQUAL(removed[0], TString("Two"));
}

Y_UNIT_TEST(Pessimization) {
TEndpointElectorSafe elector;
elector.SetNewState(TVector<TEndpointRecord>{{"Two", 2}, {"One", 1}});
elector.SetNewState(std::vector<TEndpointRecord>{{"Two", 2}, {"One", 1}});
UNIT_ASSERT_VALUES_EQUAL(elector.GetPessimizationRatio(), 0);
elector.PessimizeEndpoint("One");
UNIT_ASSERT_VALUES_EQUAL(elector.GetPessimizationRatio(), 50);
elector.SetNewState(TVector<TEndpointRecord>{{"Two", 2}});
elector.SetNewState(std::vector<TEndpointRecord>{{"Two", 2}});
UNIT_ASSERT_VALUES_EQUAL(elector.GetPessimizationRatio(), 0);
}

Y_UNIT_TEST(Election) {
TEndpointElectorSafe elector;
elector.SetNewState(TVector<TEndpointRecord>{{"Two", 2}, {"One_A", 1}, {"Three", 3}, {"One_B", 1}});
elector.SetNewState(std::vector<TEndpointRecord>{{"Two", 2}, {"One_A", 1}, {"Three", 3}, {"One_B", 1}});
std::unordered_set<TString> endpoints;
// Just to make sure no possible to get more than expected
size_t extra_attempts = 1000;
Expand All @@ -158,7 +158,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) {
UNIT_ASSERT(endpoints.find("One_A") != endpoints.end());
UNIT_ASSERT(endpoints.find("One_B") != endpoints.end());

elector.SetNewState(TVector<TEndpointRecord>{{"One", 1}});
elector.SetNewState(std::vector<TEndpointRecord>{{"One", 1}});
// no preferred endpoint, expect avaliable
UNIT_ASSERT_VALUES_EQUAL(elector.GetEndpoint(TEndpointKey("Three", 0)).Endpoint, "One");
UNIT_ASSERT_VALUES_EQUAL(elector.GetEndpoint(TEndpointKey()).Endpoint, "One");
Expand All @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) {
int counter1 = 0;
int counter2 = 0;

TVector<std::unique_ptr<TTestObj>> storage;
std::vector<std::unique_ptr<TTestObj>> storage;
while (!emulator.Finished()) {
auto obj = std::make_unique<TTestObj>(counter2);
if (elector.LinkObjToEndpoint(TEndpointKey("Two", 2), obj.get(), nullptr)) {
Expand All @@ -194,7 +194,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) {

Y_UNIT_TEST(EndpointAssiciationSingleThread) {
TEndpointElectorSafe elector;
elector.SetNewState(TVector<TEndpointRecord>{{"Two", 2, "", 2}, {"One_A", 10, "", 10}, {"Three", 3, "", 3}, {"One_B", 4, "", 4}});
elector.SetNewState(std::vector<TEndpointRecord>{{"Two", 2, "", 2}, {"One_A", 10, "", 10}, {"Three", 3, "", 3}, {"One_B", 4, "", 4}});

auto obj1 = std::make_unique<TTestObj>();
auto obj2 = std::make_unique<TTestObj>();
Expand Down Expand Up @@ -280,7 +280,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) {
obj1.reset(new TTestObj());
elector.LinkObjToEndpoint(TEndpointKey("Two", 2), obj1.get(), nullptr);

elector.SetNewState(TVector<TEndpointRecord>{{"Two", 2, "", 2}, {"One_A", 10, "", 10}, {"One_C", 1, "", 1}});
elector.SetNewState(std::vector<TEndpointRecord>{{"Two", 2, "", 2}, {"One_A", 10, "", 10}, {"One_C", 1, "", 1}});

UNIT_ASSERT_VALUES_EQUAL(obj1->HostRemoved(), false);
UNIT_ASSERT_VALUES_EQUAL(obj2->HostRemoved(), true);
Expand Down
5 changes: 3 additions & 2 deletions client/impl/ydb_internal/scheme_helpers/helpers.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#pragma once

#include <client/ydb_scheme/scheme.h>
#include <vector>

namespace NYdb {

template<typename TFrom>
inline void PermissionToSchemeEntry(const TFrom& from, TVector<NScheme::TPermissions>* to) {
inline void PermissionToSchemeEntry(const TFrom& from, std::vector<NScheme::TPermissions>* to) {
for (const auto& effPerm : from) {
to->push_back(NScheme::TPermissions{effPerm.subject(), TVector<TString>()});
to->push_back(NScheme::TPermissions{effPerm.subject(), std::vector<TString>()});
for (const auto& permName : effPerm.permission_names()) {
to->back().PermissionNames.push_back(permName);
}
Expand Down
8 changes: 4 additions & 4 deletions client/impl/ydb_internal/session_pool/session_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ std::unique_ptr<IGetSessionCtx> TSessionPool::TWaitersQueue::TryGet() {
return result;
}

void TSessionPool::TWaitersQueue::GetOld(TInstant now, TVector<std::unique_ptr<IGetSessionCtx>>& oldWaiters) {
void TSessionPool::TWaitersQueue::GetOld(TInstant now, std::vector<std::unique_ptr<IGetSessionCtx>>& oldWaiters) {
auto it = Waiters_.begin();
while (it != Waiters_.end()) {
if (now < it->first + MaxWaitSessionTimeout_)
Expand Down Expand Up @@ -265,11 +265,11 @@ TPeriodicCb TSessionPool::CreatePeriodicTask(std::weak_ptr<ISessionClient> weakC
return false;
} else {
auto keepAliveBatchSize = PERIODIC_ACTION_BATCH_SIZE;
TVector<std::unique_ptr<TKqpSessionCommon>> sessionsToTouch;
std::vector<std::unique_ptr<TKqpSessionCommon>> sessionsToTouch;
sessionsToTouch.reserve(keepAliveBatchSize);
TVector<std::unique_ptr<TKqpSessionCommon>> sessionsToDelete;
std::vector<std::unique_ptr<TKqpSessionCommon>> sessionsToDelete;
sessionsToDelete.reserve(keepAliveBatchSize);
TVector<std::unique_ptr<IGetSessionCtx>> waitersToReplyError;
std::vector<std::unique_ptr<IGetSessionCtx>> waitersToReplyError;
waitersToReplyError.reserve(keepAliveBatchSize);
const auto now = TInstant::Now();
{
Expand Down
2 changes: 1 addition & 1 deletion client/impl/ydb_internal/session_pool/session_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class TSessionPool {
// otherwise returns false and doesn't not touch ctx
bool TryPush(std::unique_ptr<IGetSessionCtx>& p);
std::unique_ptr<IGetSessionCtx> TryGet();
void GetOld(TInstant now, TVector<std::unique_ptr<IGetSessionCtx>>& oldWaiters);
void GetOld(TInstant now, std::vector<std::unique_ptr<IGetSessionCtx>>& oldWaiters);
ui32 Size() const;

private:
Expand Down
4 changes: 2 additions & 2 deletions client/ydb_coordination/coordination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct TNodeDescription::TImpl {
EConsistencyMode AttachConsistencyMode_;
ERateLimiterCountersMode RateLimiterCountersMode_;
TString Owner_;
TVector<NScheme::TPermissions> EffectivePermissions_;
std::vector<NScheme::TPermissions> EffectivePermissions_;
Ydb::Coordination::DescribeNodeResult Proto_;
};

Expand Down Expand Up @@ -126,7 +126,7 @@ const TString& TNodeDescription::GetOwner() const {
return Impl_->Owner_;
}

const TVector<NScheme::TPermissions>& TNodeDescription::GetEffectivePermissions() const {
const std::vector<NScheme::TPermissions>& TNodeDescription::GetEffectivePermissions() const {
return Impl_->EffectivePermissions_;
}

Expand Down
10 changes: 5 additions & 5 deletions client/ydb_coordination/coordination.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class TNodeDescription {
ERateLimiterCountersMode GetRateLimiterCountersMode() const;

const TString& GetOwner() const;
const TVector<NScheme::TPermissions>& GetEffectivePermissions() const;
const std::vector<NScheme::TPermissions>& GetEffectivePermissions() const;
const Ydb::Coordination::DescribeNodeResult& GetProto() const;

private:
Expand Down Expand Up @@ -150,17 +150,17 @@ class TSemaphoreDescription {
const TString& GetData() const { return Data_; }
ui64 GetCount() const { return Count_; }
ui64 GetLimit() const { return Limit_; }
const TVector<TSemaphoreSession>& GetOwners() const { return Owners_; }
const TVector<TSemaphoreSession>& GetWaiters() const { return Waiters_; }
const std::vector<TSemaphoreSession>& GetOwners() const { return Owners_; }
const std::vector<TSemaphoreSession>& GetWaiters() const { return Waiters_; }
bool IsEphemeral() const { return IsEphemeral_; }

private:
TString Name_;
TString Data_;
ui64 Count_;
ui64 Limit_;
TVector<TSemaphoreSession> Owners_;
TVector<TSemaphoreSession> Waiters_;
std::vector<TSemaphoreSession> Owners_;
std::vector<TSemaphoreSession> Waiters_;
bool IsEphemeral_;
};

Expand Down
6 changes: 3 additions & 3 deletions client/ydb_discovery/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TListEndpointsResult::TListEndpointsResult(TStatus&& status, const Ydb::Discover
}
}

const TVector<TEndpointInfo>& TListEndpointsResult::GetEndpointsInfo() const {
const std::vector<TEndpointInfo>& TListEndpointsResult::GetEndpointsInfo() const {
return Info_;
}

Expand All @@ -53,7 +53,7 @@ const TString& TWhoAmIResult::GetUserName() const {
return UserName_;
}

const TVector<TString>& TWhoAmIResult::GetGroups() const {
const std::vector<TString>& TWhoAmIResult::GetGroups() const {
return Groups_;
}

Expand Down Expand Up @@ -122,7 +122,7 @@ bool TNodeRegistrationResult::HasScopePathId() const {
return ScopePathId_.value();
}

const TVector<TNodeInfo>& TNodeRegistrationResult::GetNodes() const {
const std::vector<TNodeInfo>& TNodeRegistrationResult::GetNodes() const {
return Nodes_;
}

Expand Down
Loading

0 comments on commit b5a1b59

Please sign in to comment.