Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace TMap/TMultiMap to std::map/std::multimap #10

Merged
merged 8 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions client/draft/ydb_dynamic_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon<TDynamicConfigClien
auto promise = NThreading::NewPromise<TGetNodeLabelsResult>();

auto extractor = [promise] (google::protobuf::Any* any, TPlainStatus status) mutable {
TMap<TString, TString> labels;
std::map<TString, TString> labels;
if (Ydb::DynamicConfig::GetNodeLabelsResult result; any && any->UnpackTo(&result)) {
for (auto& label : result.labels()) {
labels[label.label()] = label.value();
Expand Down Expand Up @@ -153,7 +153,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon<TDynamicConfigClien
TString clusterName = "<unknown>";
ui64 version = 0;
TString config;
TMap<ui64, TString> volatileConfigs;
std::map<ui64, TString> volatileConfigs;
if (Ydb::DynamicConfig::GetConfigResult result; any && any->UnpackTo(&result)) {
clusterName = result.identity().cluster();
version = result.identity().version();
Expand Down Expand Up @@ -185,7 +185,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon<TDynamicConfigClien

auto extractor = [promise] (google::protobuf::Any* any, TPlainStatus status) mutable {
TString metadata;
TMap<ui64, TString> volatileConfigs;
std::map<ui64, TString> volatileConfigs;
if (Ydb::DynamicConfig::GetMetadataResult result; any && any->UnpackTo(&result)) {
metadata = result.metadata();
for (const auto& config : result.volatile_configs()) {
Expand All @@ -208,7 +208,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon<TDynamicConfigClien
return promise.GetFuture();
}

TAsyncResolveConfigResult ResolveConfig(const TString& config, const TMap<ui64, TString>& volatileConfigs, const TMap<TString, TString>& labels, const TClusterConfigSettings& settings = {}) {
TAsyncResolveConfigResult ResolveConfig(const TString& config, const std::map<ui64, TString>& volatileConfigs, const std::map<TString, TString>& labels, const TClusterConfigSettings& settings = {}) {
auto request = MakeOperationRequest<Ydb::DynamicConfig::ResolveConfigRequest>(settings);
request.set_config(config);
for (auto& [id, volatileConfig] : volatileConfigs) {
Expand Down Expand Up @@ -245,7 +245,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon<TDynamicConfigClien
return promise.GetFuture();
}

TAsyncResolveConfigResult ResolveConfig(const TString& config, const TMap<ui64, TString>& volatileConfigs, const TClusterConfigSettings& settings = {}) {
TAsyncResolveConfigResult ResolveConfig(const TString& config, const std::map<ui64, TString>& volatileConfigs, const TClusterConfigSettings& settings = {}) {
auto request = MakeOperationRequest<Ydb::DynamicConfig::ResolveAllConfigRequest>(settings);
request.set_config(config);
for (auto& [id, volatileConfig] : volatileConfigs) {
Expand Down Expand Up @@ -277,7 +277,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon<TDynamicConfigClien
return promise.GetFuture();
}

TAsyncVerboseResolveConfigResult VerboseResolveConfig(const TString& config, const TMap<ui64, TString>& volatileConfigs, const TClusterConfigSettings& settings = {}) {
TAsyncVerboseResolveConfigResult VerboseResolveConfig(const TString& config, const std::map<ui64, TString>& volatileConfigs, const TClusterConfigSettings& settings = {}) {
auto request = MakeOperationRequest<Ydb::DynamicConfig::ResolveAllConfigRequest>(settings);
request.set_config(config);
for (auto& [id, volatileConfig] : volatileConfigs) {
Expand Down Expand Up @@ -410,22 +410,22 @@ TAsyncGetNodeLabelsResult TDynamicConfigClient::GetNodeLabels(ui64 nodeId, const

TAsyncResolveConfigResult TDynamicConfigClient::ResolveConfig(
const TString& config,
const TMap<ui64, TString>& volatileConfigs,
const TMap<TString, TString>& labels,
const std::map<ui64, TString>& volatileConfigs,
const std::map<TString, TString>& labels,
const TClusterConfigSettings& settings) {
return Impl_->ResolveConfig(config, volatileConfigs, labels, settings);
}

TAsyncResolveConfigResult TDynamicConfigClient::ResolveConfig(
const TString& config,
const TMap<ui64, TString>& volatileConfigs,
const std::map<ui64, TString>& volatileConfigs,
const TClusterConfigSettings& settings) {
return Impl_->ResolveConfig(config, volatileConfigs, settings);
}

TAsyncVerboseResolveConfigResult TDynamicConfigClient::VerboseResolveConfig(
const TString& config,
const TMap<ui64, TString>& volatileConfigs,
const std::map<ui64, TString>& volatileConfigs,
const TClusterConfigSettings& settings) {
return Impl_->VerboseResolveConfig(config, volatileConfigs, settings);
}
Expand Down
29 changes: 14 additions & 15 deletions client/draft/ydb_dynamic_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <util/generic/string.h>
#include <util/generic/set.h>
#include <util/generic/map.h>
tkorsi marked this conversation as resolved.
Show resolved Hide resolved
#include <util/system/types.h>

#include <memory>
Expand All @@ -22,7 +21,7 @@ struct TGetConfigResult : public TStatus {
TString&& clusterName,
ui64 version,
TString&& config,
TMap<ui64, TString>&& volatileConfigs)
std::map<ui64, TString>&& volatileConfigs)
: TStatus(std::move(status))
, ClusterName_(std::move(clusterName))
, Version_(version)
Expand All @@ -42,15 +41,15 @@ struct TGetConfigResult : public TStatus {
return Config_;
}

const TMap<ui64, TString>& GetVolatileConfigs() const {
const std::map<ui64, TString>& GetVolatileConfigs() const {
return VolatileConfigs_;
}

private:
TString ClusterName_;
ui64 Version_;
TString Config_;
TMap<ui64, TString> VolatileConfigs_;
std::map<ui64, TString> VolatileConfigs_;
};

using TAsyncGetConfigResult = NThreading::TFuture<TGetConfigResult>;
Expand All @@ -59,7 +58,7 @@ struct TGetMetadataResult : public TStatus {
TGetMetadataResult(
TStatus&& status,
TString&& metadata,
TMap<ui64, TString>&& volatileConfigs)
std::map<ui64, TString>&& volatileConfigs)
: TStatus(std::move(status))
, Metadata_(std::move(metadata))
, VolatileConfigs_(std::move(volatileConfigs))
Expand All @@ -69,13 +68,13 @@ struct TGetMetadataResult : public TStatus {
return Metadata_;
}

const TMap<ui64, TString>& GetVolatileConfigs() const {
const std::map<ui64, TString>& GetVolatileConfigs() const {
return VolatileConfigs_;
}

private:
TString Metadata_;
TMap<ui64, TString> VolatileConfigs_;
std::map<ui64, TString> VolatileConfigs_;
};

using TAsyncGetMetadataResult = NThreading::TFuture<TGetMetadataResult>;
Expand All @@ -101,17 +100,17 @@ using TAsyncResolveConfigResult = NThreading::TFuture<TResolveConfigResult>;
struct TGetNodeLabelsResult : public TStatus {
TGetNodeLabelsResult(
TStatus&& status,
TMap<TString, TString>&& labels)
std::map<TString, TString>&& labels)
: TStatus(std::move(status))
, Labels_(std::move(labels))
{}

const TMap<TString, TString>& GetLabels() const {
const std::map<TString, TString>& GetLabels() const {
return Labels_;
}

private:
TMap<TString, TString> Labels_;
std::map<TString, TString> Labels_;
};

using TAsyncGetNodeLabelsResult = NThreading::TFuture<TGetNodeLabelsResult>;
Expand Down Expand Up @@ -140,7 +139,7 @@ struct TVerboseResolveConfigResult : public TStatus {
}
};

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

TVerboseResolveConfigResult(
TStatus&& status,
Expand Down Expand Up @@ -230,20 +229,20 @@ class TDynamicConfigClient {
// Resolve arbitrary config for specific labels
TAsyncResolveConfigResult ResolveConfig(
const TString& config,
const TMap<ui64, TString>& volatileConfigs,
const TMap<TString, TString>& labels,
const std::map<ui64, TString>& volatileConfigs,
const std::map<TString, TString>& labels,
const TClusterConfigSettings& settings = {});

// Resolve arbitrary config for all label combinations
TAsyncResolveConfigResult ResolveConfig(
const TString& config,
const TMap<ui64, TString>& volatileConfigs,
const std::map<ui64, TString>& volatileConfigs,
const TClusterConfigSettings& settings = {});

// Resolve arbitrary config for all label combinations
TAsyncVerboseResolveConfigResult VerboseResolveConfig(
const TString& config,
const TMap<ui64, TString>& volatileConfigs,
const std::map<ui64, TString>& volatileConfigs,
const TClusterConfigSettings& settings = {});

private:
Expand Down
8 changes: 4 additions & 4 deletions client/impl/ydb_endpoints/endpoints_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) {
UNIT_ASSERT_VALUES_EQUAL(obj4->ObjectCount(), 1);

{
TMap<ui64, size_t> sizes;
std::map<ui64, size_t> sizes;
size_t i = 0;
elector.ForEachEndpoint([&sizes, &i](ui64 nodeId, const NYdb::IObjRegistryHandle& handle) {
sizes[nodeId] = handle.Size();
Expand All @@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) {
}

{
TMap<ui64, size_t> sizes;
std::map<ui64, size_t> sizes;
size_t i = 0;
elector.ForEachEndpoint([&sizes, &i](ui64 nodeId, const NYdb::IObjRegistryHandle& handle) {
sizes[nodeId] = handle.Size();
Expand All @@ -263,7 +263,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) {
UNIT_ASSERT_VALUES_EQUAL(obj4->HostRemoved(), false);

{
TMap<ui64, size_t> sizes;
std::map<ui64, size_t> sizes;
size_t i = 0;
elector.ForEachEndpoint([&sizes, &i](ui64 nodeId, const NYdb::IObjRegistryHandle& handle) {
sizes[nodeId] = handle.Size();
Expand All @@ -289,7 +289,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) {
UNIT_ASSERT_VALUES_EQUAL(obj5->HostRemoved(), true);

{
TMap<ui64, size_t> sizes;
std::map<ui64, size_t> sizes;
size_t i = 0;
elector.ForEachEndpoint([&sizes, &i](ui64 nodeId, const NYdb::IObjRegistryHandle& handle) {
sizes[nodeId] = handle.Size();
Expand Down
5 changes: 2 additions & 3 deletions client/impl/ydb_internal/session_pool/session_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <client/impl/ydb_internal/kqp_session_common/kqp_session_common.h>
#include <client/ydb_types/core_facility/core_facility.h>

#include <util/generic/map.h>

namespace NYdb {

Expand Down Expand Up @@ -96,7 +95,7 @@ class TSessionPool {
private:
const ui32 MaxQueueSize_;
const TDuration MaxWaitSessionTimeout_;
TMultiMap<TInstant, std::unique_ptr<IGetSessionCtx>> Waiters_;
std::multimap<TInstant, std::unique_ptr<IGetSessionCtx>> Waiters_;
};
public:
using TKeepAliveCmd = std::function<void(TKqpSessionCommon* s)>;
Expand Down Expand Up @@ -130,7 +129,7 @@ class TSessionPool {
mutable std::mutex Mtx_;
bool Closed_;

TMultiMap<TInstant, std::unique_ptr<TKqpSessionCommon>> Sessions_;
std::multimap<TInstant, std::unique_ptr<TKqpSessionCommon>> Sessions_;
TWaitersQueue WaitersQueue_;

i64 ActiveSessions_;
Expand Down
6 changes: 2 additions & 4 deletions client/ydb_params/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <ydb/public/api/protos/ydb_scheme.pb.h>
#include <ydb/public/api/protos/ydb_value.pb.h>

#include <util/generic/map.h>


namespace NYdb {

Expand All @@ -16,8 +14,8 @@ bool TParams::TImpl::Empty() const {
return ParamsMap_.empty();
}

TMap<TString, TValue> TParams::TImpl::GetValues() const {
TMap<TString, TValue> valuesMap;
std::map<TString, TValue> TParams::TImpl::GetValues() const {
std::map<TString, TValue> valuesMap;
for (auto it = ParamsMap_.begin(); it != ParamsMap_.end(); ++it) {
auto paramType = TType(it->second.type());
auto paramValue = TValue(paramType, it->second.value());
Expand Down
2 changes: 1 addition & 1 deletion client/ydb_params/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TParams::TImpl {
TImpl(::google::protobuf::Map<TString, Ydb::TypedValue>&& paramsMap);

bool Empty() const;
TMap<TString, TValue> GetValues() const;
std::map<TString, TValue> GetValues() const;
TMaybe<TValue> GetValue(const TString& name) const;
::google::protobuf::Map<TString, Ydb::TypedValue>* GetProtoMapPtr();
const ::google::protobuf::Map<TString, Ydb::TypedValue>& GetProtoMap() const;
Expand Down
9 changes: 4 additions & 5 deletions client/ydb_params/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include <client/ydb_types/fatal_error_handlers/handlers.h>

#include <util/generic/map.h>
#include <util/string/builder.h>

namespace NYdb {
Expand All @@ -27,7 +26,7 @@ bool TParams::Empty() const {
return Impl_->Empty();
}

TMap<TString, TValue> TParams::GetValues() const {
std::map<TString, TValue> TParams::GetValues() const {
return Impl_->GetValues();
}

Expand All @@ -49,7 +48,7 @@ class TParamsBuilder::TImpl {
}
}

TImpl(const TMap<TString, TType>& typeInfo)
TImpl(const std::map<TString, TType>& typeInfo)
: HasTypeInfo_(true)
{
for (const auto& pair : typeInfo) {
Expand Down Expand Up @@ -124,7 +123,7 @@ class TParamsBuilder::TImpl {
private:
bool HasTypeInfo_ = false;
::google::protobuf::Map<TString, Ydb::TypedValue> ParamsMap_;
TMap<TString, TParamValueBuilder> ValueBuildersMap_;
std::map<TString, TParamValueBuilder> ValueBuildersMap_;
};

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -153,7 +152,7 @@ TParamsBuilder::~TParamsBuilder() = default;
TParamsBuilder::TParamsBuilder()
: Impl_(new TImpl()) {}

TParamsBuilder::TParamsBuilder(const TMap<TString, TType>& typeInfo)
TParamsBuilder::TParamsBuilder(const std::map<TString, TType>& typeInfo)
: Impl_(new TImpl(typeInfo)) {}

TParamsBuilder::TParamsBuilder(const ::google::protobuf::Map<TString, Ydb::Type>& typeInfo)
Expand Down
4 changes: 2 additions & 2 deletions client/ydb_params/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TParams {
public:
bool Empty() const;

TMap<TString, TValue> GetValues() const;
std::map<TString, TValue> GetValues() const;
TMaybe<TValue> GetValue(const TString& name) const;

private:
Expand Down Expand Up @@ -75,7 +75,7 @@ class TParamsBuilder : public TMoveOnly {
public:
TParamsBuilder(TParamsBuilder&&);
TParamsBuilder();
TParamsBuilder(const TMap<TString, TType>& typeInfo);
TParamsBuilder(const std::map<TString, TType>& typeInfo);

~TParamsBuilder();

Expand Down
8 changes: 4 additions & 4 deletions client/ydb_params/params_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(ParamsBuilder) {
.EndOptional()
.Build();

TMap<TString, TType> paramsMap;
std::map<TString, TType> paramsMap;
paramsMap.emplace("$param1", param1Type);
paramsMap.emplace("$param2", param2Type);

Expand Down Expand Up @@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(ParamsBuilder) {
.EndOptional()
.Build();

TMap<TString, TType> paramsMap;
std::map<TString, TType> paramsMap;
paramsMap.emplace("$param1", param1Type);
paramsMap.emplace("$param2", param2Type);

Expand Down Expand Up @@ -187,7 +187,7 @@ Y_UNIT_TEST_SUITE(ParamsBuilder) {
.EndOptional()
.Build();

TMap<TString, TType> paramsMap;
std::map<TString, TType> paramsMap;
paramsMap.emplace("$param1", param1Type);
paramsMap.emplace("$param2", param2Type);

Expand Down Expand Up @@ -217,7 +217,7 @@ Y_UNIT_TEST_SUITE(ParamsBuilder) {
.EndOptional()
.Build();

TMap<TString, TType> paramsMap;
std::map<TString, TType> paramsMap;
paramsMap.emplace("$param1", param1Type);
paramsMap.emplace("$param2", param2Type);

Expand Down
2 changes: 1 addition & 1 deletion client/ydb_persqueue_core/impl/read_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class TUserRetrievedEventsInfoAccumulator {
size_t MessagesCount = 0;
};

TMap<TDataDecompressionInfoPtr<UseMigrationProtocol>, TCounter> Counters;
std::map<TDataDecompressionInfoPtr<UseMigrationProtocol>, TCounter> Counters;
};

// Special class that stores actions to be done after lock will be released.
Expand Down
Loading
Loading